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

      Bangle.on("swipe", (dir) => {
        console.log(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:

    E.getSizeOf(global["\xff"].watches)
    E.getSizeOf(Bangle)
    

    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.

About

Avatar for Gordon @Gordon started