Flash and RAM Usage #1602
Replies: 2 comments
-
Posted at 2022-02-02 by @fanoush 1 - not sure if "typically" but yes it can run from RAM or from flash. When in ram the parsed string of each function is in RAM (possibly minified and tokenized) as a variable. in javascript there is no big difference between variable referencing integer value, string or function object if loaded from flash the difference is that function object has pointer to string of the body which is in flash, also plain strings work like that not just functions so if code in flash has 2 it is based on number of variables (= 3 there is no performance penalty when running from internal flash, there is small one when running from SPI flash (Bangle watches) the size is defined in board files like this https://github.com/espruino/Espruino/blob/master/boards/PUCKJS.py#L25 the size is basically determined by trial and error - you check how much free RAM you have with everything built in + CPU stack and you divide size of free ram by variable size. For PUCKJS with 2756 variables it needs 35828 bytes of RAM (out of 64KB), the rest is for static C data, CPU stack and bluetooth - NRF softdevice |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-02-02 by @gfwilliams This one? http://www.espruino.com/Other+Boards It may be slightly out of date as we've tweaked the amount of available vars recently.
Espruino will execute JS direct from flash (as long as you save using the IDE and not the
It's the total number of variables the board supports. It's basically address size. Now, the situation is a bit more complex as some boards use 13/14/15 bytes for variables as they're able to pack the addresses a little more tightly.
There's no huge performance penalty for executing from Flash on most boards. There is a bit on Bangle.js because the flash chip is external, but on everything else flash is tightly coupled to the chip so isn't noticeably slower than RAM. These should help: http://www.espruino.com/Code+Style#other-suggestions |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-02-02 by Eric24
Somewhere I recall seeing a table (or similar) of the amount of free flash and RAM available for JS on the various devices, and how many JS variables it would support, but I can't find it now. Can anyone point me to it?
Also a few related questions:
Beta Was this translation helpful? Give feedback.
All reactions