Asking help to add fastloading to TerminalClock

Posted on
  • I keep going back to it and I have no idea why there is still a memory leak when uncommenting the remove method.

    I welcome any help or tips ;)

    The code is here : https://github.com/espruino/BangleApps/b­lob/c0d301c1e7c59a1d8e1714cdd5b51deeb7a7­ae6b/apps/terminalclock/app.js

  • At first glance I would suspect #L176 being called on every lock and then setting a new timeout without clearing the old one. It should be a fairly tiny memory leak if this is the reason, the timeout only can accumulate over 45 seconds.

  • Thanks,

    I did the changes on my repo (https://github.com/Stiralbios/BangleApps­) and it didn't solve the issue. The memory leak is quite high (~450) so it's probably something big that isn't unloaded like a module but I don't see how.

    >eval(require("Storage").read("terminalc­lock.app.js"))
    =undefined
    >process.memory().usage
    =1529
    >Bangle.setUI()
    =undefined
    >process.memory().usage
    =1419
    >eval(require("Storage").read("terminalc­lock.app.js"))
    =undefined
    >process.memory().usage
    =1979
    >Bangle.setUI()
    =undefined
    >process.memory().usage
    =1867
    >eval(require("Storage").read("terminalc­lock.app.js"))
    =undefined
    >process.memory().usage
    =2425
    >Bangle.setUI()
    =undefined
    >process.memory().usage
    =2313
    
  • I meant calling something like if (clock.turnOffServiceTimeout) clearTimeout(clock.turnOffServiceTimeout­);
    to remove the timeout handler. Deleting the variable only removes the timeout id from memory until it is set again in the next line.

  • Thanks, fixed it but the memory leak is still here

  • Change #L95 from

    if (this.onPressure) Bangle.removeListener('onPressure', this.onPressure);
    

    to

    if (this.onPressure) Bangle.removeListener('pressure', this.onPressure);
    

    ('pressure' not 'onPressure')

    should fix it.

  • Thanks it fixed it. It was a dumb mistake XD

  • @BartS23 once again to the rescue! 😉

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

Asking help to add fastloading to TerminalClock

Posted by Avatar for Stiralbios @Stiralbios

Actions