• 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.

  • 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

    var memStart;
      memStart = process.memory(true);
    
    function doBuzzer(e)
    {
      Bangle.buzz(1,1);
    
      var memTmp = process.memory(true);
      var used = memTmp.usage - memStart.usage;
      print(": Udiff:"+ used.toString() + " used:" + memTmp.usage.toString() + " free:" + memTmp.free.toString() + " total:" + memTmp.total.toString()  );
    }
    
    
    Bangle.on("touch", doBuzzer);
    
About

Avatar for user140377 @user140377 started