LOW_MEMORY error when loading app #1354
Replies: 13 comments
-
Posted at 2019-12-10 by @gfwilliams The issue you're hitting is that when you upload via the IDE, the code is executed/interpreted as it is uploaded - the actual JS text never exists in Bangle.js's RAM in one big block. When you save to a file, Espruino has to load that whole file into RAM and execute from there. So if you have to split the file up to save it, you may well hit issues trying to load/execute it too :( You've got two main options I guess:
I'm planning on adding the ability to execute JS code directly from external storage which would basically solve all your issues, but that's going to need a bunch of testing before I can put it live. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-10 by @allObjects Does having the application in modules (and storing them as functions) help?... because I just ran into same issues. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-11 by feugy Hey folks! few takeaways:
@allObjects my source code is split in different modules, and I use rollup & babel to transpile and bundle them in one file. Is there a way to split the app on the Bangle itself, using different "files" in storage? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-11 by @gfwilliams
Yes - this might help :) http://www.espruino.com/Modules#from-storage Depending on the images, they may be eating up a bunch of space. You can store those in storage and load them as needed. A bit like is done for https://github.com/espruino/BangleApps/tree/master/apps/animals
I'm not sure IDE minification will have much effect then. The code you uploaded definitely looked like minification could help it significantly though.
... for now :) At some point I think I will have to add the ability to execute code from Storage, so when that happens it'll be fine. I'll also be extending the IDE and command-line tools to do the chunking automatically though, so that should help you out |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-11 by @allObjects
Yep... everyone goes thru that transformation w/ or for tech / physical imlementation... architecturally / logically though one can still stay on the high road. I 'grew up' w/ 16..19 k for app, data and even system utils, such as ISAM / keyed access of records... that makes you focus a lot and forces you to choose your memory battles. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-14 by feugy I've manage it with a better minification (thank you "terser's mangle" option!). One thing I'd like to confirm. Is the difference due to the app launcher itself? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-14 by Robin Sat 2019.12.14 What is the size of the app being run @feugy? Having the value free before upload and the difference in both cases would help here. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-15 by feugy Hi Robin. I've update the links above: Here is an example of a run (press button 2 to start, button 1 to pause, then button 3 to stop and reset):
Now, the same code, but saved in Storage under "activities" name: Long press Btn 3 to get the clock, then goes to settings, select "activities" and start/pause/stop
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-16 by @gfwilliams Are you using an up to date bootloader and settings app from https://banglejs.com/apps/ ? Also, if you do There were some issues with the old one (like leaving clock source code around). There's actually an issue tracking this at espruino/BangleApps#65 - I may modify things soon to really make sure everything is torn down before an app gets run. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by feugy You where right @gfwilliams. Running the code: > initial 694
1053
1053
1053
903
905
916 Running as an App > initial 771
974
974
824
856
856 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-16 by @gfwilliams Hi - please can you try updating the Bangle.js interpreter firmware to the latest version from http://www.espruino.com/binaries/travis/master/? This morning I pushed some changes which execute code directly from the external flash memory by default. It means that any function that you have defined in a file that's in flash memory will have its code executed directly from flash without using up RAM. It will hopefully help you significantly |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-16 by AkosLukacs w00t :) Reading your other comment, is this for strings stored in external flash? Or is this for general javascript execution / module loading? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-16 by @gfwilliams It's Bangle only, because that's the only one where Storage isn't in flash memory that is memory mapped. Code executed from Storage on other platforms has always just referenced the memory rather than copy it to RAM first |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-10 by feugy
Hello there!
When I upload my code from the Web IDE to the watch, it runs as expected.
https://www.espruino.com/ide/?gist=9df129529bccc133f9f82bf7b39de48f&upload
(shows you current time and start message, until you press button 2 which stops everything)
I am trying now to store it as an app.
The code string is big (18 156 chars), so it is split in chunks and writes gracefully in file.
https://www.espruino.com/ide/?gist=3fddc28e3188fd5f5cded6aa1d037cb0&upload
But when I launch the app from the app launcher, I get:
Any hints on how I could troubleshoot this?
I have LOW_MEMORY issues when reading my app from storage.
The app is quite big: the code string is 18 156 characters long.
Beta Was this translation helpful? Give feedback.
All reactions