Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#10206 closed defect (fixed)

fix memory leaks

Reported by: bill Owned by: bill
Priority: high Milestone: 1.4
Component: Dijit Version: 1.4.0b
Keywords: Cc:
Blocked By: Blocking:

Description

Ticket for fixing memory leaks in themeTester.html or other places, found from http://blogs.msdn.com/gpde/pages/javascript-memory-leak-detector-v2.aspx

Change History (16)

comment:1 Changed 10 years ago by bill

(In [20647]) Just fixing some comments I noticed while working on memory leaks, refs #10206 !strict.

comment:2 Changed 10 years ago by bill

(In [20648]) On page unload, clear any focus manager references to widgets or dom nodes, to avoid memory leaks on IE. Refs #10206 !strict.

comment:3 Changed 10 years ago by bill

(In [20649]) Fix typo, refs #10206 !strict.

comment:4 Changed 10 years ago by bill

(In [20650]) Fix TabContainer? memory leaks, refs #10206 !strict.

comment:5 Changed 10 years ago by bill

(In [20651]) More standard way to monitor clicks on the widgets, refs #10206 !strict.

comment:6 Changed 10 years ago by bill

(In [20652]) Avoid leak warning due to test, refs #10206 !strict.

comment:7 Changed 10 years ago by bill

(In [20654]) Seems there's no need to create a function in the global scope everytime there's code in markup like onclick="console.log('hello world')"... creating a local variable works fine and avoids the IE memory leak. Refs #10206 !strict.

comment:8 Changed 10 years ago by bill

(In [20656]) Cancel onkeydown handler on page unload, to prevent IE leak, refs #10206 !strict.

Moving away from putting all the destruction code in the dijit._destroyAll() method, in order to keep initialization code and corresponding destruction code next to each other.

comment:9 Changed 10 years ago by bill

(In [20662]) Code to deregister iframes/main window to avoid memory leaks on IE. Also, about mousedown listener, switched to using attachEvent()/attachListener() rather than dojo.connect() because the latter leaves a dojo._ieDispatcher() handler on dojo.doc (even after the dojo.disconnect() call), which causes a leak warning.

This change solves the leak, although could probably come up with a better design for the handle returned from registerWin()/registerIframe(). But that's an implementation detail. I was also conflicted about whether unregisterIframe() should take a handle or a reference to the iframe; ended up passing in a handle, like dojo.disconnect().

comment:10 Changed 10 years ago by bill

(In [20669]) Fix unbindDomNode() when called on <body> (which happens when contextMenuForWindow==ture), refs #10206 !strict.

Even though the connects are on the document, the bind-id is stored on <body>, so look it up from there.

comment:11 Changed 10 years ago by Douglas Hays

(In [20672]) References #10206. Change Slider destroy method to clean up parasitic widgets who attach as children to templates DOM nodes.

comment:12 Changed 10 years ago by bill

(In [20683]) dojo.connect() to <html> rather than document to avoid [reports of] memory leaks on IE6. [8245] put in code to attach to document rather than <body>, and although attaching to <body> doesn't work for right-click, I didn't see any problems attaching to <html>. Tested on IE6, IE8, FF3.5 and Safari for both Shift-F10 and right-click. Refs #10206 !strict.

comment:13 Changed 10 years ago by bill

(In [20684]) Delete focusNode along w/editNode since they point to the same thing, refs #10206 !strict.

comment:14 Changed 10 years ago by bill

(In [20685]) Make focus manager monitor <html> rather than document on IE, to avoid memory leaks. This doesn't work for FF though, so leaving connection to document for other browsers. Refs #10206 !strict.

comment:15 Changed 10 years ago by bill

Resolution: fixed
Status: newclosed

That clears up all the memory leaks while loading (then immediately closing) themeTester, there are probably some more but they can be filed as separate tickets.

comment:16 Changed 10 years ago by bill

(In [20687]) Better way to get <html> node from document (thanks James), refs #10206 !strict

Note: See TracTickets for help on using tickets.