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.
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...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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...