-
• #2
ther is no max safe number , it depends on complexity of your code. what happens when it is too much is that CPU stack grows too much down and overwrites application data - JS variables but also other random data. You can try to paint CPU stack with some known pattern at startup time and then figure out how much the stack grows down with your javascript code. Then you could tune variables to that.
process.memory().stackEndAddress
is where firmware data in RAM ends so the CPU stack must not grow down to hit it. you can fill RAM with poke32 from that adddress at boot time and see how much gets overwritten as your js code runs and stack grows down.also this stack painting at startup could be part of the firmware, I have somewhere patch for this to do it as first thing before espruino starts
-
• #3
makes sense. I'll just keep it at the default ~2700 that the regular build has it at in that case. last thing I want is random undefined behavior because I tried to push the number too high.
thanks for the tip!
Heya, I'm trying to figure out a way to determine the absolute max safe amount of RAM I can give to my custom Puck firmware build.
I've found the Puck starts behaving unpredictably around 3500 variables. I'm using the minimal build with only Bluetooth and NFC enabled, if that's relevant. Is there any way I can see what the max safe number of variables would be for this build?