Memory leak for require(sdk/tabs)

54 views
Skip to first unread message

Gabriel Ivanica

unread,
Dec 20, 2014, 12:23:03 PM12/20/14
to mozilla-la...@googlegroups.com
Hi,
    Today I realized that require('sdk/tabs') leaks memory... quite some if you ask me... around 100MB RAM for around 50 windows opened and then closed
    Long short story.... I created a jetpack add-on a while ago... I checked for memory leaks in about:memory and realized that leaks memory every time I open a new window... Seems that every single new window created and then closed will remain in --top(none)/detached and Garbage Collection will never free that space.
    Since I was creating XUL overlays with Addon SDK (so.. working at the browser window level not add-on) I thought that it was a error from my code and after countless days of tracking I realized that I will probably never find the problem and decide to keep the addon just for myself... I never expected that a simple require for a SDK module to be the problem

    Today I decided to check again the problem and realized that a simple require('sdk/tabs') does the trick... basically I created a simple addon with just 3 lines in main.js
   
                            var tabs = require('sdk/tabs');
                            exports.main = function (options, callbacks) {};
                            exports.onUnload = function (reason) {};

    Steps to reproduce:
            1) install the add-on (I used the latest available SDK 1.17, but from what I know it should use the one integrated in Firefox...)
            2) open as many new windows as you want then close them (leave 1 open)
            3) about:memory - measure memory, look for --top(none)/detached
           
4) Garbage collection or cycle collection or minimize memory usage does nothing

        - you can wait as much as you want but that memory will never be freed... tried that
        - tested on a clean profile with Firefox 34, seems that Nighly will never free the memory even if I disable the addon

            5) disable the add-on
            6) do a GC or wait for it
            7) measure memory usage => memory is freed

    I created a test addon:  https://www.dropbox.com/s/j3d4iq5gqn8ql3a/leak-test.xpi?dl=0
   
    Can anyone please confirm this memory leak bug? I couldn't find it on Bugzilla... and still not sure If I'm doing something wrong or not, but In 3 lines of code I guess I shouldn't :D
    How does this affect add-on reviews ?
    I know a lot of people that don't close Firefox too often and during a full day of browsing (or maybe more), several windows can be opened .. 2MB for every single opened window is something

Thanks a lot,
Gabriel Ivanica

   

Erik Vold

unread,
Dec 22, 2014, 4:13:08 PM12/22/14
to mozilla-la...@googlegroups.com
Hey Gabriel,

I tried an add-on with just `let tabs = require("sdk/tabs")` with version 1.17 of cfx, and this was hit and miss, two tries out of a few I did notice a leak.


Erik



Gabriel Ivanica

unread,
Dec 22, 2014, 5:30:13 PM12/22/14
to mozilla-la...@googlegroups.com
Hi,
    Opening tabs and then closing them probably will not trigger this problem... at least I didn't notice it at all.
    I was talking about opening new Firefox windows and closing them. I can reproduce this 100% of the time ... please take a look at this
    https://www.dropbox.com/s/oh50af399opesix/sdk-tabs-memory-leak.png?dl=0

Thanks,
Gabriel
Reply all
Reply to author
Forward
0 new messages