Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1930 closed defect (fixed)

dojo.event.disconnect (kwDisconnect) can cause memory leaks in IE

Reported by: ornus Owned by: alex
Priority: high Milestone:
Component: Widgets Version: 0.4
Keywords: memory+leak disconnect Cc: sol@…
Blocked By: Blocking:

Description

I'm not sure in which situation leak can occur. one specific example I have encountered is with context menu and treeV3. when menu unbinds from the tree and disconnects from it, the tree dom node remains in memory and eventually causes a leak. I have encountered this problem both in IE7 and IE6. in some situations it's rather small (200K), but it can be big (2MB+)

#1928 is related ticket with description of a specific example.

Change History (8)

comment:1 Changed 13 years ago by bill

Can you give an actual testcase? Preferably something completely automatic, so I just have to press a button to see the memory go up.

comment:2 Changed 13 years ago by alex

Resolution: invalid
Status: newclosed

so it's worth noting that disconnect (and kwDisconnect) does not destory a join-point (the inteception object that manages function dispatch for connect()'d items). Instead, it removes entries from the connection list tables of each join point. This means that references to elements that you may be "disconnecting" are still held by the joinpoints.

To entirely "clobber" the joinpoint, call something like this:

dojo.event.kwDisconnect({ /*params*/ }).unintercept();

the "unintercept" call will effectively destroy the joinpoint in question, which is returned from connect, disconnect, and the keyword variants of both.

Marking "invalid" unless and until a better test case is filed.

comment:3 Changed 13 years ago by ornus

Resolution: invalid
Status: closedreopened

this doesn't actually work. disconnect returns *false* as far as I can see.

I think I wasn't clear explaining the situation. I'm sorry. disconnect doesn't cause the leak on its own. memory doesn't go up when it's called. it does something that makes it impossible for IE to release DOM node when the page unloads.

for example, when menu binds to the tree DOM node it connects to it. if at somepoint (even if it's during unload) the menu unbinds from the tree DOM node by calling disconnect, IE is unable to unload the tree DOM node from memory. I used Drip to detect and locate the problem.

to reproduce the problem you can open "testswidget reeV3menu1.html" and refresh the page, or navigate to *about:blank* and back. either way when the page unloads IE leaks about 150-200K on my PC. in scenario where where I use menu and tree the leak is 1.5M. I'll try to build a test case that would leak as much to make it easier to see if the problem is present or not.

anyway, if I go to the PopupMenu2 code and comment out call to disconnect in unBindDomNode the leak dissapears.

comment:4 Changed 13 years ago by ornus

actually I found out that leak size depends on whether dojo is baked or not. when I'm using baked *dojo.js* the leak is 1.5-3MB, when I use small trunk *dojo.js* the leak becomes 200KB. if I change *testswidget reeV3menu1.html* to use release baked dojo instead of trunk one the leak goes up to 1.5-3MB. somehow I feel this could be related to #1144

comment:5 Changed 13 years ago by alex

Owner: changed from bill to alex
Status: reopenednew

comment:6 Changed 13 years ago by alex

(In [6627]) ensure that disconnect returns a joinpont object. Refs #1930

comment:7 Changed 13 years ago by alex

Resolution: fixed
Status: newclosed

(In [6628]) prevent un-necessaray joinpoint creation that was leaking memory in an unloading race. Fixes #1930. Thanks to ornus for his patient help and persistence.

comment:8 Changed 12 years ago by (none)

Milestone: 0.4.1

Milestone 0.4.1 deleted

Note: See TracTickets for help on using tickets.