I posted the question below as a problem in a new post:
Hi all and thanks for taking the time to read this.
I've been struggling for a long time now to try solve what I believe it's a bug on jQuery library.
First, the memory leak I've identified is only applicable to IE and I tested on IE 7 only.
I used IEJSLeaksDetector to identify the leak point and it points me to this portion of jQuery js file:
- // Only use addEventListener/attachEvent if the special events handler returns false
- if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) {
- // Bind the global event handler to the element
- if (elem.addEventListener) {
- elem.addEventListener(type, eventHandle, false);
- } else if (elem.attachEvent) {
- elem.attachEvent("on" + type, eventHandle); //<------------ Source of the leak
I've confirmed that this is the critical point because by commenting this line out, the leak disappears alongside with the functionality that depends on it.
My asp.net application builds up about 4MB of memory on explore after each page refresh.
The main elements that generate this are:
window
document
A
DIV
Note that DIV is actually an element managed by jQuery UI that makes a slide-out pane on the page. The other elements I've not created myself and seem to be related to some inner workings of jQuery on a page that has very few usage of jQuery like a few selectors and two ajax calls.
Yet it indefinitelly builds up around 4 to 5MB of memory usage.
I tried a lot of stuff to attempt to fix the memory leak, but no matter what, still some reference or closure seems to stay back with this making IE not release the memory used.
By the way, the version of jQuery I use is 1.7.1 and I can't change it since the newer versions are not backwards compatible to this one. Also, I noticed that the newest version has the exact same code like the one I provided.
The jQuery UI version I use is 1.8.16 (also tried latest version, but did not solve the memory leak problem).
Also, calling the detachEvent right after the attachEvent also works, but before it didn't solve (had a js mess). I've performed a cleanup on javascript so now calling detachEvent works, but still I lose the functionality.
I'm out of ideas here, so if anyone could shed a light, I would really appreciate it.
Thank you very much.
Regards,
Fábio