views:

899

answers:

3

I am trying to fix memory leaks in IE 7. Using Drip for investigations but it is not helping much when most dynamically generated DOM elements do not have unique ids.

Tips?

+1  A: 

Just remember that memory leaks are really about you not cleaning up after yourself. All you need is a little organization.

In the past, I have created my own proxy object for attaching events to DOM elements. It uses my javascript library's api to actually set and remove events. The proxy itself just keeps track of all of the references so that I can call a method on it to have it clean up all of my potential memory leaks.

For my purposes, I was able to just call a single deconstructor on the page that would clean up the leaks for the entire page when the user was leaving the page.

You may have to be more granular but the technique is the same.

Justin Bozonier
I am using GWT that have a custom event system for avoiding closure related memory leaks in event handlers.http://code.google.com/p/google-web-toolkit/wiki/DomEventsAndMemoryLeaks
Tahir Akhtar
+4  A: 

You should try the Javascript Memory Leak detector developed internally at Microsoft.

Eran Galperin
Thanks.I will be trying it
Tahir Akhtar
Just looking at the site seems like this is what I was looking for. It seems to be far more capable debugger than the one I was already using.
Tahir Akhtar
But it will always detect on unload of the page. And IE7 recovers the leaks on unload.. so how do you check in IE 7?
Sabya
+3  A: 

Well, Your best bet is to understand what causes them, so you can look critically at your code, identify patterns that may cause a leak, and then avoid or refactor around them.

Here's a couple of links to get you started, both very informative:

Dan
Thanks Dan,Actually I have already read up on it including the second article you mentioned. I am using GWT with very little JSNI so many memory leak patterns are automatically taken card of. Still seeing some leaks, but the debugger just shows the elements like TABLE involved in leak.
Tahir Akhtar