views:

213

answers:

4

Our team is faced with slow but serious Javascript memory leak. We have read up on the normal causes for memory leaks in Javascript (eg. closures and circular references).

We tried to avoid those pitfalls in the code but it likely we still have unknown mistakes left.

I started my search for available tools but would like input from people with actual experience with these tools.

Some of the tools I found so far (but have no idea how good and useful they would be for our problem):

Our search is not limited to free tools, it will be a bonus, but more importantly something that will get the job done.

We do the following in our Javascript code:

  • AJAX calls to a .NET WCF back-end that send back JSON data
  • Manipulate the DOM
  • Keep a fairly sized object model in the Javascript to store current state


Edit: I have updated this question in a last attempt to get more views on this question. Normally I don't do this but we are a bit desperate getting a resolution to this issue.

+1  A: 

A way to track memory leaks in Firefox is with the Leak Monitor Addon. It shows memory leaks of javascript (including extension-scripts).

Please remind that the plugin will sometimes show leaked objects that will get cleaned up later by the garbage collection. If that is the case the plugin will launch a new window showing you the new status.

Brij
This tools seems to only track a specific type of error geared to browser extension developers. Nevertheless we gave it a try but it didn't report anything for our particular problem.
Philip Fourie
+1  A: 

I have used the JavaScript Memory Leak Detector and I can tell you it works great.

What dynamic engine are you using? Based on the mention of a .Net web service, I'm guessing that you are using ASP.Net. Is that correct? You may want to look at the ASP.Net AJAX JavaScript library. It was built in a way that helps this situation. All components have a dispose() method that allows you to remove references to DOM objects. When I switched to ASP.Net AJAX, my page became much more responsive.

Gabriel McAdams
This tool looked promising but never reported anything at all; the controls always stayed empty. Come to think of it might be that it doesn't run on IE8. I will try it again on IE7 and report back.Thanks for the tip on the AJAX Javascript library. Our solution uses custom Javascript components with JQuery, so it would not work for us.
Philip Fourie
Yeah. This tool is for IE versions before IE8. That is because the memory leak issues they test for have been fixed in IE8. If the memory leaks you spoke of occur in IE8 (or Firefox, etc), then I don't think any of these tools will be able to help you. They test for code that causes leaks in IE versions before IE8.
Gabriel McAdams
+2  A: 

sIEve is for memory leaks in IE specifically. What I like about it is that you can reliably reproduce the steps used and capture action-able data. See the following:

http://stackoverflow.com/questions/1261244/how-to-use-ie7-javascript-memory-leak-detectors

George Jempty
Thanks we gave it a try. Not a bad tool. It worked on IE7 but not on IE8. We still couldn't work out what is causing the leak with this tool, might be because we didn't use the tool correctly...
Philip Fourie
+1  A: 

Another tool for you: JavaScript Memory Validator.

Shows allocations, objects, hotspots, generations, snapshots, etc.

Works with Firefox 1.0 through 3.6.

Stephen Kellett
Was pleasantly surprised with this tool. Maybe the best of the ones we evaluated. It is a bit unpolished on the edges. Crashed a couple of times and was really slow, but got the job done albeit a bit frustrating to use.
Philip Fourie