-
• #2
I found that I can nest modules...
trandi.wordpress.com/2016/04/24/espruino-mpu6050-digital-motion-processing/However, I still get the out of memory error.
-
• #3
Is that
process.memory()
that you put what you get right after uploading?It's possible that it's not the code that's using up memory, but stuff that it allocates (arrays/etc?)
Having said that, 20k of code is quite a lot for a module. At the moment, to load it Espruino ends up having to store the same thing 3 separate times (momentarily), so that's ~60kB, which is going to end up being too much.
It might be worth looking at http://www.espruino.com/Performance for some ideas about how to save memory/get your module size down.
You should definitely try and avoid stuff like
getFoo = function() { return foo; }
though (if you have them) - it wastes space and slows execution down quite a lot on Espruino... -
• #4
Yes, it is the right after uploading. How do I read the actual available space out of that command?
I will take a look at the stuff allocation then, and reducing the size of the module.
Thanks a lot!
-
• #5
The thing in the code that kills is - I guess -
DMP_MEMORY
. I did not investigate what and how it is used, but a similar approach put me out of memory (describing the PacMan Maze/Board... I resorted to a custom encoding and some processing (post #3) to create the runtime structure and values out of it with 'auto-delete' of the 'source' - inplace/replace withthis.x = processed(this.x);
)...DMP_MEMORY
is about 6K - from originally about 12K - of your 20K .md code. Does that sound about right?If you can compress/pack this information and use initialization code to unpack and remove, that could help. --- Is and always will be true:
memory * cycles = C
(C is mystery, but 'constant').@tve was exploring - AND ENABLING - other options to get more memory: write certain things into the unused flash pages and get them - in this case whole modules - at runtime on demand from there. Same approach is taken to store other big junks, such as certificates for SSL/encryption/...
-
• #6
How do I read the actual available space out of that command?
You just need
process.memory().free
. On Espruino boards each var is 16 bytes, so just multiply the value by 16 to get bytes.And
.usage
is your actual program size
Hi,
I'm new to the forum and to Espruino Pico. I've been working on a module that is now about 20K minimized (closure - simple). I started to get EEROR: Out of Memory! if I add more prototypes. I'm not very familiar with how the Pico memory works and if there is any option to keep adding more prototypes to the module instead of moving some of the prototypes to the main code. That last option seems to work, but it is not the best choice for me.
In case it helps...
Thanks,
Gabe