views:

78

answers:

2

I am experiencing a memory leak in IE that occurs upon a page refresh (as I described in this SO post).

All I want to know at this point is: is there a way, on the document "unload" event (which could get called when the page refreshes or closes), to clear EVERYTHING? I'm looking for a simple solution that would ensure that everything gets destroyed in order to avoid the leak. Is this even possible, or do I have to continue looking into the details of the leak and fixing it on an object by object basis?

Update: Ok maybe I wasn't descriptive enough. I can't (at least I dont think I can) just set all of my objects to null: I have event handlers for click events etc. so the application needs to be "live" constantly until it is closed. Also if I then think about just nulling everything out in an "unload" method (called when the page is exited), then all my objects would have to have global scope (right)? What is the best way to remedy this? Is there a way to get a list of all referenced objects so I can null them? Should I add every object I use to an array so that I can dereference it later?

A: 

try window.onbeforeunload or window.onunload and set the variables you use to null. or you looking for something more?

gp
I know how to get the unload event, I'm just trying to see if there is a way to null out everything without dealing with individual variables.
hhj
A: 

Set your objects to null and they won't be leaked.

jeffamaphone