question

Patrick Zweekhorst avatar image
1 Like"
Patrick Zweekhorst asked Patrick Zweekhorst commented

FlexSim crash with preemption of tokens

Hi,

I have a small example model that keeps crashing on seemingly random moments. FlexSim just crashes and is closed. When I create less tokens it will work so I think the logic is fine, but I cannot test it completely. There are 3 delay activities where the tokens whose Shift label is not the same as the preempting token are removed from. After8 hours (a shift) they are placed back in the delay and the same procedure starts again. I assume it is a memory issue, so I would really appreciate it if someone could take a look at the model and let me know where it goes wrong.

Many thanks in advance,

Patrick

testmodel.fsm

FlexSim 18.1.2
process flowpreempting
testmodel.fsm (22.0 KiB)
· 4
5 |100000

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

Emily Hardy avatar image Emily Hardy ♦ commented ·

In the 18.2 beta the Token class has new stop() and resume() methods. This could be something interesting for you to try out for your model.

1 Like 1 ·
Patrick Zweekhorst avatar image Patrick Zweekhorst Emily Hardy ♦ commented ·

Hi @Emily Hardy,

Thanks for the suggestion. That does seem to be working the way I want. As I understand this works more or less the same as preempting, when you do not want to something with the preempted token. (Which is exactly what I want). The model with preempting should however also work I think.

0 Likes 0 ·
tannerp avatar image tannerp commented ·

I am not sure what you're modeling, but it appears that your tokens never end up going anywhere. It might be a good idea to put a sink somewhere to get rid of tokens, otherwise you're just creating an infinite amount and causing the model to crash.

0 Likes 0 ·
Patrick Zweekhorst avatar image Patrick Zweekhorst tannerp commented ·

Hi @Tanner Poulton,

I am modelling some order creation process which starts after the Variation delay. For now we can just add a sink there, as in the attached model. Now FlexSim does not crash all the time, but it still does quite often. If there is no crash of FlexSim I get the following exception:

time: 57600.000000 exception: Error: Invalid token reference at save context activity "Save Context" in "ProcessFlow". Must be a valid reference to a token.

The time this error occurs seems to be different each time. Also if I take a look at the token in the Save Context activity I see a problem. The Array that should contain all the released tokens in it has some invalid pointers. This is however not possible, since the released tokens just stay in a dummy custom code activity.

Also no sink in the model should not let FlexSim crash. In another dummy model I can make millions of tokens and FlexSim stil does not crash.

Thanks for your time.

testmodel.fsm

0 Likes 0 ·
testmodel.fsm (22.4 KiB)

1 Answer

Jordan Johnson avatar image
1 Like"
Jordan Johnson answered Patrick Zweekhorst commented

This appears to be a bug in the splice() method (used in the Append to Array pick option). Even if the token only enters the Assign preemptTokens activity, the model still crashes. Using the append() method does not seem to have the same problem.

testmodel-fixed.fsm


testmodel-fixed.fsm (21.9 KiB)
· 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.

Patrick Zweekhorst avatar image Patrick Zweekhorst commented ·

Hi @jordan.johnson,

Many thanks for this solution. I would have never found that problem myself.

Patrick

0 Likes 0 ·