question

Guillaume M2 avatar image
0 Likes"
Guillaume M2 asked Ryan Clark commented

Stack overflow on moveobject

Hello,

I am currently working on a project where FlexSim has to communicate with an external application. To summarize, when this application sends a message via socket, we create an flowitem in the model() (via the c++ module loaded in flexsim with a dll) then we add labels to this object and finally, we move the flowitem in a queue. As soon as the flowitem enters the queue, it generates a token in a processflow and the simulation goes on...

The problem I have now is that I have a "Stack overflow detected" error randomly when calling the moveobject function. As I say, this exception is random, I can generate a hundred objects without any problem but after a while, the exception is generated.

In the model tree, I can see is that the object is not moved in the queue (still in the root of the tree). After that the whole c++ module seems to stop working (If I don't catch the exception, the whole program crashes).

What would you recommend to avoid this mistake? I have already tried some things, whithout success :

- Use insertcopy and then destroy

- Create directly the object in the queue (but by adding the labels after, the results are not good in the simulator)


Thank you.


FlexSim 20.0.10
flexsim 20.0.10moveobjectdll errorstack overflow
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ryan Clark avatar image Ryan Clark commented ·

Hi @guillaume.m2, was Phil BoBo's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Phil BoBo avatar image
0 Likes"
Phil BoBo answered Phil BoBo edited

Use a Delay activity with 0 time in order to split the processing into multiple events rather than synchronous calls on the stack.

Troubleshooting Process Flows - Using 0 Second Delays (flexsim.com)

Delay Activity (flexsim.com)

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Guillaume M2 avatar image Guillaume M2 commented ·

OK thank you. Where should I put the event ? At the beginning of the processflow where the tokens are released ? In the C++ part just before or after the moveobject?

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Guillaume M2 commented ·

I don't know. I don't have your model in front of me to know what it is doing or why. All I have is this statement from you:

"As soon as the flowitem enters the queue, it generates a token in a processflow and the simulation goes on"

If you are using a Wait For Event listening to OnEntry, then all the processing of that activity and subsequent activities is handled synchronously within the moveobject() call. Put the Breathe after the Wait For Event activity so that it finishes moving the item in before executing the rest of the Process Flow logic.

All the processing of the queue's logic for sending items happens synchronously as well when an item is moved into it. So if you have ports and logic that fires a bunch of synchronous functions on the stack in that logic, you might want to use delayed messages to split that up as well.

Without more information, I can't tell you exactly what to do. I'm just trying to explain the general solution to the issue so that you can understand what is happening and fix your code accordingly.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.