Closed Bug 71623 Opened 24 years ago Closed 17 years ago

leaks caused by ownership cycle through event listeners and JS

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME
Future

People

(Reporter: dbaron, Assigned: saari)

References

()

Details

(Keywords: helpwanted, memory-leak)

DESCRIPTION:  Without the fix for bug 31847, I'm seeing leaks loading
http://www.people.fas.harvard.edu/~dbaron/dom/test/two-events/EventTarget
and pressing the button.

The cause of the leaks seems to be (I think!):
 * nsJSDOMEventListener objects own an nsJSContext (mContext)
 * the nsJSContext has a rooted script object (why?)
 * this root prevents the document from being GCed
 * the document owns the nsEventListenerManager
 * the nsEventListenerManager owns the nsJSDOMEventListener (cycle)

The fix to bug 31847 obviously entrains a lot more stuff in this leak since that
fix essentially adds ownership where we needed ownership to prevent a crash.
Keywords: mlk
So when are you seeing the leaks?  Of the 7 listeners on the page I can see the 
3 that get removed getting destroyed.  If I switch pages a couple times I can 
see the other 4 get removed when the GC eventually collects the script objects.  
Running WinNT with a few local changes though I don't think offhand they'd 
affect leakage.

On a side note on the test case, the capturers will start working with the fix 
in my tree now.  Not sure if you just haven't gotten around to updating stuff 
but 'currentNode' was changed to 'currentTarget'.  Bubbles and cancelable work 
also, at least locally for me.
David, could you confirm that this still happens?  I wonder if GC just hadn't 
yet fired.  Also wonder if Tom's fix has solved it.
This does still happen.  joki's right that it isn't really a problem though,
except that it makes leak finding harder.  That jscontext_savedroot gets
unrooted if I go to a different page before exiting.
Futuring since we can live with this one and Joki is swamped.
Keywords: helpwanted
Target Milestone: --- → Future
QA contact updated
QA Contact: gerardok → madhur
Blocks: 92580
No longer blocks: 92580
QA Contact: madhur → rakeshmishra
QA Contact: rakeshmishra → trix
.
Assignee: joki → saari
QA Contact: trix → ian
Maybe duplicate of bug 241518 if the problem still exists.
We don't leak on this test anymore, marking WFM.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → WORKSFORME
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.