Out of memory tricks? #5067
Replies: 1 comment
-
Posted at 2015-10-15 by @allObjects At this moment I do not have an Espruino board at hand to make a comparison of free space after reset and after requiring the module. I assume the modulle that is pulled from the Web is the minified version... http://www.espruino.com/modules/BMP085.min.js. I pulled the code, did some formatting, and you might shrink it a bit more by dropping some of the debug stuff... also some shortening of member (value/function property) names can help.
Here is what I manually did to it:
And the attached file is the above code with tabs and new lines removed. I hope I did not mess with essentials... of course, it is a 'different' module... but constraints justify many means... ...reduction by 1374 bytes down to 2255 bytes... yes, looking at the code, it creates quite a lot of things... Attachments: Posted at 2015-10-15 by tve It gets minified. After loading it "only" uses ~420 JSvars, but during loading the string itself makes it all blow up.
Posted at 2015-10-15 by @allObjects I was not aware of the fact that the debug stuff is dropped automatically... so the savings are not that much as I calculated. I'm also not sure if we are talking about exactly the same module, because there is some code I cannot find in.... NEVER MIND... pulled something else to work on than BMP085... ~~~{:( Posted at 2015-10-15 by @allObjects BMP085.min.js formatted:
There is not much you can do about... I just wonder what the nested inline runtime function creation does to memory consumption... Posted at 2015-10-16 by @gfwilliams Hmm - interesting that the initial string itself makes it blow up. No sure what to suggest - I imagine that the 12 byte JsVars mean it's not quite as efficient at storing data in the normal, extendable String format Posted at 2015-10-16 by tve Do the 12-byte JSvars not support the extendable string format? Posted at 2015-10-20 by @gfwilliams Oh, they do - but as each var needs a pointer and flags, the efficiency goes down.
Potentially the extra 2 bits for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-10-15 by tve
I'm trying to load the BMP085 module onto an esp8266 with 800 JSvars and I'm getting an our of memory error when the IDE loads the module:
I have 760 free JSvars after a reset:
Does it make sense that this is not enough for this small module? Are there any tricks I could employ?
Beta Was this translation helpful? Give feedback.
All reactions