Finding memory leaks in JavaScript using firebug?

Are there any add-ons for Firefox that I can use to find out with part of the JavaScript causes memory leaks?


Solution 1:

I've got nothing for firefox, but the webkit inspector in Chrome has a profiler built in that is great for that kind of thing.

As an added bonus it also shows you all browser events such as repaints, so you can engineer your code to have the least impact on the browser.

Solution 2:

Use Drip.exe / IEleak, I used it a lot to search for memory leaks!

Other hits:

  • jQuery itself prevents a lot of memory leaks!
  • Test your code with http://jslint.com
  • There is a tool by Microsoft itself, but I don't know it is up to date: http://blogs.msdn.com/b/askie/archive/2008/12/31/javascript-memory-leak-detector-for-internet-explorer.aspx
  • There is also integration with Visual Studio: http://berniesumption.com/software/how-to-debug-javascript-in-internet-explorer/
  • There is a good article about mem leaks http://www.ibm.com/developerworks/web/library/wa-memleak/
  • http://www.debugbar.com/?langage=en

Solution 3:

The best memory profiler I've found is for IE (supports even IE6 ;-). Give it a go - you will be surprised how good it is:

http://ajax.dynatrace.com/ajax/en/