Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflow exception #24

Open
kjorgensen opened this issue Apr 14, 2022 · 2 comments
Open

StackOverflow exception #24

kjorgensen opened this issue Apr 14, 2022 · 2 comments

Comments

@kjorgensen
Copy link

I have a state machine that loops around for more than 256,000 times and I eventually get an error The maximum number of stajavascript:void(0);ck frames supported by Visual Studio has been exceeded. Is there a workaround for this. I can see in the call stcack there are now breaks.

@guFalcon
Copy link
Member

Uh. Hi there. It's been a few years since I've had a look at this repo, but I think your problem lies with the stack-function of the machine.
You're running into a memory-overflow with C#. Let me explain...

Furthermore it implements even a Stack-Based-FSM (SBFSM). So you may tell it to 'continue with the last state before the active one'.

The stack-function means that you may 'take a step back' after a series of inputs.
That of course means, that it has to record all of the inputs.

So you have several options here.

  1. Disable the stack function, if you don't really need the 'take a step back' functionality by calling popStack() (by not calling EnableStack() in the builder (see Unit-tests))
  2. Call ClearsStack() more frequently (since your users won't actually believe your software would be able to 'undo' the last 256,000 steps of inputs). Calling this function actually clears the call-stack, thus preventing the overflow (again... see unit-tests and search for 'stack')

let me know if that made sense,
Gerald

@kjorgensen
Copy link
Author

Thanks Gerald for your quick reply, that is really awesome of you to help me out. I was using the EnableStack and ClearStack and doing a clear for each time around a loop of about 8 substates. I was using a thread sleep and and then calling a trigger in each entry function. Somehow I think this does not allow for the system to clear the stack. I switched out the thread sleeps with a timer and a callback and then the whole system worked.

I do not see the popStack function in the unit tests? And the builder did not allow it in the fluent syntax. Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants