Firefox Memory Leak

Recently our original article/rant on Firefox’s legendary memory abuse has seen an increase in comments and views; and I had intended to post the following comment in light of the article’s rebirth and the ensuing discussions in the comments.

  1. Firefox Memory Leak 2020 Reddit
  2. Firefox Memory Leak Ubuntu
  3. Firefox Memory Leak Windows 10

The reply turned out to be longer than I’d originally intended, so here it is as its own post.

I’ll try to be as objective as possible in this reply:

I've discovered there is a memory leak in Firefox 3.6.3 using Spiceworks 4.7.50804 on Windows 7 Ultimate x86. The PC has 4 gb RAM so even with the leak it is not running out or RAM, but does get very unstable. Most memory leaks in Firefox are caused by developers of extensions and developers that use JavaScript in web pages. The main cause of this is not cleaning up event handlers on unload. Also from time to time there are memory leaks and regression bugs in Firefox itself, mainly with alphas and betas.

The most important thing for frustrated end users to keep in mind is that Mozilla/Firefox cannot be held responsible for cases where incorrectly written plugins and/or extensions cause Firefox to abuse system memory – that’s the trade-off between empowering developers and keeping the code squeaky clean.

Most of the cases reported are indeed caused by one or more extensions or plugins gone awry, doing something they shouldn’t be doing, or something they don’t know how to do properly. Some of the most popular plugins for Firefox are notorious for their memory leaks; but few users realize just how dangerous they can be, and that the Firefox devs cannot really do anything about it.

Firefox Memory Leak

At the same time, there can be no doubt that Firefox has some memory leaks in the codebase itself. They’re clearly not easily reproducible and they don’t happen very readily nor often enough because the developers have clearly spared no effort in their attempts to address this problem for once and for all. But they’re there, nevertheless.

No matter how you look at it, the fact remains that under certain circumstances, doing certain stuff on certain machines in certain ways for certain people, Firefox still leaks memory. A lot. On Mac, Windows, and Linux. Yes, on clean installs too.

Firefox Memory Leak 2020 Reddit

Now as a systems developer (Mac, Windows, and Linux w/ their respective native APIs; embedded systems; .NET and more with years of experience), I must say that of all the bugs and problems I’ve ever encountered, there is nothing that “cannot be fixed.” To say that this behavior is out of Firefox’s hands because it’s not their code that’s causing the problem is simply not true.

Firefox Memory Leak Ubuntu

I’ve experienced memory leaks like this (and worse) in my own code in the past, largely due to stupid mistakes and silly oversights. It takes extreme persistency to make memory leaks go away – a willingness to spend 24 hours on-end & non-stop crawling through code, memory dumps, and stack traces to try and find out where things are going wrong. It requires remote debugging on allegedly-affected machines. It requires reading through dozens to hundreds of sometimes clueless users describing in the most general of terms what they were doing when things went wrong. In short, it requires a lot of effort and very little recognition and a hell of a lot of hair-pulling.

But it can be done.

C++ is an incredibly powerful language. If you know the code you’re developing and the systems you’re writing it for, there’s nothing you cannot fix. Dynamic memory allocation is the biggest gift/curse in the world, but in C and C++ if you can allocate something that means you can free it. Even if you don’t have a mechanism to find out where it is and how it got there. But you just have to be cunning enough to figure out how to track them down and set them free, taking care to know when and where to do so safely…. and you have to be familiar with every single routine and how they work; which is obviously extremely difficult with codebases as large and complicated as Firefox’s.

There are even workarounds for the memory leaks (assuming they can be isolated) if the developers aren’t willing or capable of doing the aforementioned. If you’re dealing with leaky libraries that you can’t fix, in the very worst-case scenarios you can hook into them at runtime, access the functions you need, reserve the memory required, get the job done, copy only what you need, then free it right back. All of it. You can have helper threads or processes handle this stuff then wipe them and their memory spaces clean when they’re done to complete the memory insulation.

There’s a lot of stuff that can be done, and none of them are easy. But the journey of a thousand miles begins with a single step, and developers and evangelists denying a problem exists isn’t the way to go about addressing the matter at hand.

At the end of the day, Firefox is a great browser and any complaints about its performance and its shortcomings are only out of a sense that it can do better – that it has to in order to remain at the top of its game in a cutthroat market of only the most intense of competition.

edited April 2015 in Priority support

after using :
DTInstances.getLast().then(function (dtInstance) {
dtInstance.DataTable.rows().invalidate().draw(false);
});
to apply sort, IE and Firefox crash after period of time and when checking memory for IE and Firefox, memory increasing

please, check the following URLs for images contain memory progress in ie :

Memory

http://54.191.119.153:8080/static/ie-21.png
http://54.191.119.153:8080/static/ie-22.png

«12»

Replies

Firefox Memory Leak Windows 10

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Hi,

    Are you using the latest version of FixedColumns (per the discussion in your other thread) when doing this test? The current release will unfortunately have a memory leak as it isn't releasing all of its event handlers.

    Regards,
    Allan

  • i am testing on fixedColumns v3.0.4 and before that and now testing in fixedColumns v3.0.5 all have the same issue
    please, i need to know which release contain the fix of this issue and when????

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    If the latest FixedColumns didn't fix the issue, this is unfortunately likely to be quite difficult to debug. I will get back to you when I have more information.

    Regards,
    Allan

  • please, i need to fix this issue my app force close in Firefox and IE
    i have updates every 2000 update per second
    this issue not acceptable for my environment

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    2000 updates per second?! That's a lot!

    I'm still looking into what is causing this issue I'm afraid. However, with that many updates per second, the workaround we came up with in one of your other threads to invalidate the whole table on each update is not a good one. I will also need to spend some time looking into your code to suggest a more efficient way of doing it.

    I'll reply back when I have more information.

    Allan

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Another update - I'm quite certain that the issue is in FixedColumns and I'm reasonably sure that it is to do with how FixedColumns is cloning the header cells from the original DataTable for display in the fixed columns. It will copy all of the header cells, but not all are displayed, which means they don't have their event handlers removed when they are destroyed.

    How exactly to correct that is something I am still working on.

    Regards,
    Allan

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    I've just committed a couple of fixes for memory leaks in FixedColumns that should address the leak you are seeing here. Could you try using the nightly version of FixedColumns please? The build date is '23rd Apr 2015, 15:34'.

    Thanks,
    Allan

  • Thanks for reply
    i admit memory leaks reduced but still exist memory leaks
    my memory leaks test : http://54.191.119.153:8080/static/performance.png

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Could you possibly update your static/grid.html page with the latest code and I'll take a further look into what is happening.

    Memory is always difficult!

    Thanks,
    Allan

  • updated : http://54.191.119.153:8080/static/grid.html

  • edited April 2015

    I have big another Big issue when hide same columns and reorder columns they back all to show columns can you test it in http://54.191.119.153:8080/static/grid.html just try to reorder with column with auto sort

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Thanks for the update.

    It would appear that there are three areas in the FixedColumns code where events are being cloned from the source DataTable (for example the click to sort on column header event) which are not being removed when the table is being fully redrawn each time. I will continue to look into this and let you know how I get on.

    Regarding the column reordering issue - I suspect that at least part of the issue will be with the rapid updating of the data. Unfortunately the support credits have run out now so I won't be able to look into this immediately (I'm actually not sure that there is a possible fix for this one), but I will continue to look into the memory issue as priority support and hopefully get back to you soon.

    Regards,
    Allan

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Hi,

    I've just committed an update for FixedColumns that corrects the memory issue that can be seen in your demo. Thanks again for putting that up!

    The latest FixedColumns nightly contains the fix and running your demo locally shows its memory use remaining stable.

    Regarding the column visibility, I had a little look at this. It appears to be caused by a listener that the Angular DataTables code adds that will destroy the DataTable when ColReorder has finished its reordering. The whole lot is then recreated, but with the original column visibility applied. What is interesting is that this isn't 100% reproducible - sometimes I need to try it a couple of times to trigger the error. It might be worth asking in the angular-datatables repo issues about this one as I'm afraid I have no knowledge of Angular myself.

    Regards,
    Allan

  • edited June 2015

    Hi,
    i sent to you before about problem in fixed column and you sent new version, but i still have big performance issue make my app very slow because of memory leak
    and when disabling fixed column, no memory leak happened
    i attached links for testing for memory leak with fixed column and without it :

    and i have url for you to test the problem :

    username : mai002
    password : kn123456

    please click on refresh icon (in black square in attached image) more than one time to see the memory leak issue

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Thanks for the update. Unfortunately I'm not managed to get the time to take a look into this yet. I will try to do so as soon as possible.

    Allan

  • Hi Allan,
    we are in closer phase of project and this is very critical for us

  • Hi Allan,
    i want ask you if we renew our support, you can help us to fix this issue

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Hi,

    Yes, that would certainly allow me to prioritise this work over the other work that I am doing. I hope to look at this later this week even if you don't renew the support option. But purchasing support would make certain of it, and it would be done sooner rather than later.

    Regards,
    Allan

  • Hi,
    i purchased support, please we need your priority in this issue

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Fantastic - thanks. I'm looking into this just now and will get back to you as soon as possible.

    Regards,
    Allan

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    I sent an e-mail a little while ago, it is possible it didn't get through so I'm posting here as well just in case!

    The links above does appear to be working at the moment. Could you possibly give me an updated link or bring the server back online so I can do a little bit of testing with your pages.

    Thanks,
    Allan

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Great - thanks.

    Sorry to ask for one more thing - it appears the websocket that is being used is not resolving:

    ws://dev-dummy:61614/stomp' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

    Unfortunately I'm struggling to reproduce the issue at the moment, so I thin I will need to be able to use your page to recreate the problem for diagnosis.

    Regards,
    Allan

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    That's excellent - thank you.

    Could you confirm if I need to perform some action such as toggling table sorting, or tabs or something else to cause the memory leak to appear? I've just been running a memory trace in IE for the last 3 minutes and it is holding at a fairly static value.

    Many thanks,
    Allan

  • Allan,
    over on the header that write on it orders details and you can find refresh button please click on it many times i set between in black square
    you can find it in this image http://kncairo.kn-it.org:8087/Etrade-Plus/resources/fixedColumn.jpg

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Fantastic - thanks for pointing that out! I've just been debugging this and I'm fairly certain that it is a conflict between DataTables an Angular when destroying a table - the way DataTables operates means that the Angular destroy method on the nodes doesn't occur, which results in an event being retained - hence the issue.

    I'm going to experiment a little bit more before committing the change required in DataTables. I'll do this first thing tomorrow morning and get back to you then. Hopefully that will resolve the issue!

    Allan

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    I've just committed the fix that I think is required to address this. I'm not able to test this directly on your system of course so it is possible that I've not fully fixed the issue, but I am hopeful that it will address it fully.

    To test, if you could try using the 1.10.8-dev version of DataTables on your page, that would be great.

    Many thanks,
    Allan

  • Hi Allan,
    i put the file DataTables 1.10.8-dev, and tell me if you need to change any others files

  • Posts: 52,889Questions: 1Answers: 8,129Site admin

    Thank you - unfortunately that doesn't appear to have fixed the issue after all. There is still an Angular hook somewhere that it causing the leak.

    The site runs exceptionally slowly on my machine making debugging it really difficult, so I'll need to spend a bit of time trying to recreate the issue locally and debug further. I'll get back to you when I have some more information.

    Thanks,
    Allan