• Hello everybody.

    This is my second attempt to write an app for Football Officiating and ran into problems again. Graphics and Buffers are not my friends, I think.

    The code is growing, but the simple switch from my main screen and the menu (BTN3) back and forth is somehow poluting my memory (it grows 1% every switch).

    Before using the Menu-Component I thought my solution with resizing and clearing the buffer is a good idea. Maybe someone has a better solution for a non flickering output?

    Code is attached (too long).

    1 Attachment

  • Hi! I think one thing that might be hurting you is:

      Bangle.on("swipe", (dir) => {

    Because I don't think you ever remove this listener, so each call to pageMain it gets added - and it's not just the size of the function, but because it's inside another function the whole scope of that function gets saved away too.

    There may also be some watches you're not removing too.

    You could try:


    And see if you can see any one of those growing in size for each switch.

    The most common memory hog with the menus is if you do menu["menuitem"] = functionName; as functionName gets called with the menu as an argument, and you end up with a reference to the last menu kept in scope all the time. However you don't seem to be doing that which is great - instead you do menu["menuitem"] = function() { functionName(); }.

  • Hi @Gordon. Happy new year and thank you for the hints. Didn't know about the E-getSizeOf(x)-method. Very helpful. I will search for my memory eaters.

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

Switching between Menu and rendered content is blowing memory

Posted by Avatar for AxelRHD @AxelRHD