"MEMORY_BUSY" - when is it thrown or printed?

Posted on
  • After a program continued to run but no longer drew any graphics, I tried to isolate the error - particularly, because it drew its graphics without any problems while the LCD display was "off", but stopped doing so when it was turned "on" (or the screen locked and unlocked)

    Interpreter error: [
    New interpreter error: MEMORY_BUSY

    As this message does not seem to crash my application: when is it thrown or printed to the console?

  • What surprises me: I do not seem to consume that much memory (measured with process.memory():

    before I start drawing:

     { "free": 10203, "usage": 1797, "total": 12000, "history": 70,
      "gc": 0, "gctime": 23.59008789062, "blocksize": 15, "stackEndAddress": 537087280, "flash_start": 0,
      "flash_binary_end": 582576, "flash_code_start": 1610612736, "flash_length": 1048576 }

    after drawing:

    { "free": 10197, "usage": 1803, "total": 12000, "history": 70,
      "gc": 0, "gctime": 23.52905273437, "blocksize": 15, "stackEndAddress": 537087280, "flash_start": 0,
      "flash_binary_end": 582576, "flash_code_start": 1610612736, "flash_length": 1048576 }

    Thus, there seems to be (and should be) plenty of memory left?

    Or does the graphics buffer consume a lot?

  • Someone else asked this in http://forum.espruino.com/conversations/­371207/#comment16338013

    MEMORY_BUSY happens when something is happening to the variable store which keeps it busy (that usually means garbage collection) and a new variable is requested from inside an interrupt.

    It's a flag (E.getErrorFlags) that gets set when the error happens (as it may be in some code that executes in a place where data can't be output to the console) and next time around the idle loop the interpreter picks it up and displays the message.

    It should be extremely rare especially on Bangle.js 2, so it'd be great if you could find a way to reliably reproduce it. It's possible you have some app that is forcing a garbage collect which is making it more of a problem though? On Bangle.js 2 GC passes should be super rare given the amount of RAM available.

    Ideally you could post up the simplest possible test case? I guess it's possible that if you're allocating a big graphics buffer each time you render, eventually Bangle.js has to defragment? Even so, vars should usually not need to be allocated in IRQs

  • Thanks for explanation!

    No, I could not reproduce that message. Indeed, it pointed me in the wrong direction when I was looking for the reason of an error - the cause turned out to be s.th. completely different (as one can see from the memory reports)

    Thus, it looks more like a "transient"

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

"MEMORY_BUSY" - when is it thrown or printed?

Posted by Avatar for Andreas_Rozek @Andreas_Rozek