I am having some memory leak problems in IE.
I have been reading, that not unhooking event handlers in IE, could cause memory leaks. Is this true?
Could my memory leaks be cause by not detaching event handlers when the user leaves a page?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Douglas Crockford has an excellent post on JSscript memory leaks (JScript is IE’s implementation of JavaScript/ECMAScript).
It basically comes down to this: IE has separate memory management (and thus garbage collection) for the DOM and for JScript. Because of this, IE has trouble cleaning up the cycling references between DOM objects and event handlers.
The way to work around this is to make sure that you always remove the event handlers from the DOM objects (or set them to
null) before you throw away the DOM object.