You are reading a single comment by @Swordstone_ and its replies. Click here to read the full conversation.
  • 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

  • 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!


Avatar for Swordstone_ @Swordstone_ started