callback, LOW_MEMORY, MEMORY errors

Posted on
  • Hi guys,

    I'm developing a clock app for my Bangle watch and am running into memory issue (I think).
    My watch shows a 'callback' error at the bottom of the screen after some time and stops updating the time. A bit later it displays a 'LOW_MEMORY, MEMORY' error and only manages to display my date border. I don't seem to have this issue when using other clocks.

    I'm a spoiled javascript developer that never had to think about memery usage too much and I'm struggling quite a bit in this low memory environment. Can someone point me to some tips or documentation for working in such an environment?

    The code for my app can be found here > https://github.com/jbrems/BangleApps/blo­b/feat/skyrimclock/apps/skyrimclock/app.­js

    Thanks,
    Jonas

  • For Espruino, reducing the character count really helps a lot.

    Maybe for date border, you can try drawing a static image instead of drawing it algorithmically? That way you just need to save the bitmap.

    Moving the logo out of a function should also help reduce reinitializing the var whenever it's called.

  • Thanks for quick response parasquid!

    I have implemented your suggestions and have a lot less code now :)

  • You're welcome :) I can see that you used heatshrink as well, hopefully that helped too (sometimes it's larger for less compressible data but ymmv).

    Looking forward to seeing your watchface!

  • Can someone point me to some tips or documentation for working in such an environment?

    See https://www.espruino.com/Performance maybe some parts are too low level but there is a lot of tips there (strings, typed arrays,...).

  • Good read!

    Moving the logo out of a function should also help reduce reinitializing the var whenever it's called.

    My bad here, looks like this won't matter since it looks like Espruino won't reinitialize the String anyway. This is just me being sensitive to these things because of how React behaves :P

  • This would be a good help - notes specifically for Bangle.js:

    https://www.espruino.com/Bangle.js+Guide­lines
    and also https://www.espruino.com/Code+Style#othe­r-suggestions

    Moving the logo out of a function should also help reduce reinitializing the var whenever it's called.

    Sorry this one is bad advice... you want to define big chunks of data inside functions - because functions are stored in and executed from Flash (of which you have 4MB) whereas you only have 64k of RAM so you want to reduce the stuff you keep in that to a minimum.

    Could be worth setting 'Debug Info' to 'show' in the settings page too. That way if there's an error (eg when callback is shown) when you're not connected by Bluetooth it'll write the stack trace to the screen.

    The code you've got there looks good though - there doesn't seem like there would be anything that'd cause memory usage to keep increasing...

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

callback, LOW_MEMORY, MEMORY errors

Posted by Avatar for jbrems @jbrems

Actions