Debugging memory usage

Posted on
  • I just added a tool at­ew/

    This tool allows you to connect to an Espruino/Bangle.js device via Web Bluetooth and then display the contents of RAM as a Network.

    It’s a good way to look into your code and see if there’s anything obviously using memory that shouldn’t be.

    It's a bit of a hack right now but it is very useful, if only to look at what's going on inside Espruino - so any PRs to make it work better would be hugely appreciated!

  • That's really neat. I tried it on my Bangle and also an emulated Bangle (ROCK). On the Bangle, ROOT is the centre of the network while the ROCK has two centres Hidden Root and Timers - a much larger network since everything is written in Espruino. BTW - what network display code are you using? - the animation and layout is very impressive.

  • ...ready for the art gallery (sorry @Gordon: had to sign it w/ espruino 22 )

    1 Attachment

    • artByEspruino.png
  • wow, this is very helpfull!

    1 Attachment

    • 3B4DA1A9-4DE1-4F60-BC1D-4F7174F43532.png
  • I am not able to fully comprehend this graph, but I am seeing this dandelion like structure from my Bangle 2. Is this normal?

    1 Attachment

    • 20220203-085215.jpg
  • Great - glad it's helpful! The graph vis is - I tried this a while ago (you can see E.debugVariables got added a long while back) but never found something that would visualise it properly before.

    The complaints about Recorder using a bunch of RAM got me to try it again, and as it happens I spotted some ways the interpreter could save some memory, so firmwares from the last day should be a bit more frugal.

    @Raik that's cool. What you're seeing there is a bunch of JS arrays (one var per index element). You can see they're all referenced from one point (another array?) which it itself referenced from ROOT (you can see the red line).

    Not sure what clock face you have, but it's possible that it could be using a Typed Array instead, which wouldn't need all the index vars so could save a decent amount of memory.

    I guess these sorts of things would be good in the README to give an idea about what to look for

  • Not sure what clock face you have

    I'm using the Numerals. Ah, those plumes originated from the numerals polygon definition then.

    var numerals = {

    I'll see how I could be rewriting this.

  • That looks like the issue then :) Ideally you'd put it all in one big Uint8Array, but while not optimal, what is there may not be the end of the world

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

Debugging memory usage

Posted by Avatar for Gordon @Gordon