You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I haven't looked into your code I'm afraid, but when memory isn't freed in menus, I find it's often because of something like this:

    function menuA() {
      console.log(process.memory().usage);
      E.showMenu({
       one : menuB
      })
    }
    
    function menuB() {
      console.log(process.memory().usage);
      E.showMenu({
       two : menuA
      })
    }
    
    menuA();
    

    The problem here is that E.showMenu calls functions with menu as an argument. Even though the argument isn't used in either menuA/menuB it's still there (in case some code in the function used arguments) so you're stuck with this chain of references.

    If you use () => menuA() instead of just menuA then that ditches the argument, and memory isn't leaked

    function menuA() {
      console.log(process.memory().usage);
      E.showMenu({
       one : () => menuB()
      })
    }
    
    function menuB() {
      console.log(process.memory().usage);
      E.showMenu({
       two : () => menuA()
      })
    }
    
    menuA();
    
About

Avatar for Gordon @Gordon started