4

Halo All, I'm new to javascript and Jquery. I'm working on analysing the memory leak of a thick client application running on IE8.

This application uses one HTML with multiple javascript pages. I checked the application and found that the variables created in some pages are still alive even after the call of destroy function.

I want to write a generic function to kill all global variables that were not destroyed in the destroy function.

Can someone please help me with this? Also, let me know the techniques to reduce memory leakage.

Many thanks in advance

1

1 Answer 1

3

Created this jsFiddle. Essentially based around the following:

for (x in window) {
    delete window[x];
}

Obviously with a bit more involved, but that's the core.

Tested in Chrome. Should work elsewhere.

Sign up to request clarification or add additional context in comments.

1 Comment

Chad - Many thanks for your help... It helped me to destroy all the global variables. I read on the internet that Closures might be one of the major reasons for memory leakage. Can someone kindly let me know if it is necessary to kill all the local variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.