confused about E.memoryArea #5319
Replies: 1 comment
-
Posted at 2016-05-05 by @gfwilliams Well, at the moment your code is executed from flash, but 'executing' here is means that the function declaration is being executed from flash (but then the execution of the declaration loads it into RAM). While Espruino could store the code in flash directly, if you then did So what you could do is:
Or actually you could do some fixup code like:
Not tested, but something like that should work. Posted at 2016-05-05 by @gfwilliams If you try the builds from GitHub as of just now, I've enabled the native string copying. I guess we'll see if anyone complains - the main issue I see is using the new But on the plus side, you should save some memory when using it, as all functions declared in the root scope will then have their code in flash. Posted at 2016-05-06 by tve Ah, very interesting! What I would love to achieve is to be able to move modules into flash. I hope to get two benefits from this: reduce RAM consumption and also reduce code load time when iterating on app code (under the assumption that the modules don't change). Posted at 2016-05-06 by @gfwilliams This should allow that if each string sent to Modules.addCached is a native string - but the function declarations themselves will stay in RAM, so it's only the code that ends up in flash. In a module with lots of small functions you may not see any difference at all (in fact it could be worse). I probably ought to add some code that checks the length of the function. Anything 10 chars or less is better stored in RAM (because the Native String takes up a var anyway). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-05-05 by tve
I'm a bit confused about "executing out of flash memory" using E.memoryArea. Here's what I tried on an esp8266.
First write a simple function to flash memory and check that it's there:
Now eval it (I know I didn't need "ma"):
Now see what's in memory:
Doesn't this mean that the function "hello" uses just as much memory as if it had been normally loaded, or is #138 really all in flash and doesn't use any jsVars?
Is there a different trick that's eluding me here to get the code in "hello" to stay in flash? Or am I just confused?
Beta Was this translation helpful? Give feedback.
All reactions