how to free memory from calling Bangle.buzz ? #6201
Replies: 1 comment
-
Posted at 2023-09-09 by user140377 Could it be that your loops are keeping the CPU so busy that it can not run the garbage collector to cleanup the memory? Try the following: Wait a bit, do nothing and check the memory again. Or use setTimeout/Intervall() to trigger buzz and memory logging. Posted at 2023-09-09 by joyrider3774 Hi, thanks for your answer, the example functions above are indeed not good, but in my game the game is idle if no input has happened and it never garbage collects, however i now found out this issue only appears in the emulator in the browser on the pc, when i tested it on the device itself with my game it works fine but somehow in the espruino ide and emulator using same code from my game when calling bangle.buzz never gets freed and eventually when enough buzzes had past even with very long delays between input and code execution it never garbage collects it. I should have tested on the device first but i was mainly developping in the ide with the emulator as it works a bit faster. I still don't know why the emulator does not free the memory. but i have created a better example code: each time you do a touch on the screen memory keeps increasing and never gets released in the emulator, i did touches with pauses in between until memory was exhausted and it did not garbage collect. On the device itself it actually behaves fine and memory remains stable but in the emulator in my chrome browser it does not and keeps increasing until enough buzzes have been done for the memory to be exhausted if you comment bangle.buzz the issue never happens
Posted at 2023-09-09 by user140377 Looks fine to me:
Posted at 2023-09-09 by joyrider3774 ah good to know it does not happen with you in the emulator (on pc / browser) this is what i get and it never decreases but on the bangle itself it works fine
I'll see if i can pinpoint something on my pc / browser that can affect this, just to be sure you ran the code in the emulator or on the bangle itself ? the emulator is where i seem to have the issue Posted at 2023-09-09 by user140377 ah sorry, no this is on the bangle. Sounds like an emulator bug. Posted at 2023-09-09 by joyrider3774 yeah indeed, on the bangle it works fine for me also i was not aware of that initially, so that makes me less worried. I should test more on the bangle also when running in such things. On the bangle memory remains the same as well for me but not in the emulator. I have not tried a different browser yet. I even went as far and "touched" a 1000 times to see if it would eventually crash in the browser using the emulator and it did, but on the bangle its indeed fine which is a relieve Posted at 2023-09-11 by @gfwilliams Ahh, thanks - yes, this looks like an emulator bug. I guess because the emulator can't 'Buzz' it's not implemented, so a promise gets made and returns but it is never resolved and stays in memory |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2023-09-09 by joyrider3774
Hi,
in my game when i call Bangle.buzz free memory keeps decreasing until it runs out of memory. I noticed in the documentation it says it returns a promise but i'm not familiar with them and i don't know how i should use Bangle.buzz so it does not keep eating free memoy or how to free the memory from probably the returned promise.
for example when testing i tried this code and it runs out of memory when doing this resulting in an error:
I'm not sure if i'm doing something wrong here but it shows something like this as a result
Beta Was this translation helpful? Give feedback.
All reactions