I am getting stack overflow problems and I can clearly see that it happens with the introductions of some new arrays. I cannot find the option to increase the stack size on the soft PLC (Twincat) running on my machine.
Any help is appreciated
I am getting stack overflow problems and I can clearly see that it happens with the introductions of some new arrays. I cannot find the option to increase the stack size on the soft PLC (Twincat) running on my machine.
Any help is appreciated
I'm currently using 4024.7 and there you can change the stack size under SYSTEM > Real-time. And then under the Settings tab you'll find Maximal Stack Size [kB].
Here is the official answer that I got from Beckhoff:
You can’t change TC3 stack size, it use fix size of 60KB. Only function uses the stack memory, FBs & programs not.
The stack size is very limiting. You can't do large memory operations inside function. Also you can stack limited number of functions in one operation.
Still, Beckhoff may increase the stack size in future versions of TwinCAT 3.
I realise this is a little late, but instead of trying to increase the stack size, you can take steps to reduce the size of the stack you need. When calling a method or function, try passing in a reference to an existing array and using that for the calculation. Even if it is for some intermediate processing that isn't returned directly as your response, this will dramatically improve your stack management. There are two way to manage this in TwinCAT.
The easy way is to create a VAR_IN_OUT variable to pass in. This works well, but you should not be using this if your block calls the variables from other methods. The other way is to pass in a REFERENCE TO your ARRAY and using that.
This approach will work for both returned and intermediate processing type issues.
regedit: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Beckhoff\TwinCAT3\System add a costum DWORD with the key: DefaultStackSize value: Hex(80) or Decimal(128)
this will set your stacksize to 128 instead of 64 :) change it to whatever you want, not sure what happens when it's too high. but this works, we use it on all our PLC's as we always have issues with the amount of strings parsed with Json converters etc.
this works with 4022.xx versions of twincat. trailed and tested for a couple of years already.