• Okay @Gordon... I have finally got the reason why my App code is failing and sample code is working. I decided to read the compact documentation more closely to realise it fails if there isn't enough RAM. Digging through the code showed me it needs atleast allocated + 1024 to continue with compact. I haven't traced it as far as how much is allocated but when I have my app loaded and I run process.memory() I get this:

    process.memory();
    ={ free: 1036, usage: 1064, total: 2100, history: 7,
      gc: 0, gctime: 3.72314453125, blocksize: 16, "stackEndAddress": 536923400, flash_start: 0,
      "flash_binary_end": 483876, "flash_code_start": 1073741824, flash_length: 524288 }
    

    Even if allocated is 126 or 256, we can see the amount of free memory (1036) isn't enough for compact to continue.

    However, the reason my sample above kept working is because on a Bangle with everything erased, if I run process.memory() I get the following:

    >process.memory();
    ={ free: 2056, usage: 44, total: 2100, history: 7,
      gc: 0, gctime: 2.99072265625, blocksize: 16, "stackEndAddress": 536923400, flash_start: 0,
      "flash_binary_end": 483876, "flash_code_start": 1073741824, flash_length: 524288 }
    > 
    

    This means, require("Storage").compact() is ineffective if you have Bootloader + Default Launcher + Battery Widget + BT Widget + Settings and 1 clock App.

    How we resolve this I am not sure, maybe after erase compact is called without the check for minimum RAM? Will that work? I have to dig deeper, but essentially we have an issue where we are unable to realise the full potential of Bangle and the storage it has.

About

Avatar for PiOfThings @PiOfThings started