Closed
Bug 274793
Opened 20 years ago
Closed 16 years ago
leaking JS atoms and GC roots
Categories
(Calendar :: Internal Components, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
0.9
People
(Reporter: mvl, Assigned: dbo)
References
Details
Attachments
(3 files)
895 bytes,
text/plain
|
Details | |
958 bytes,
text/plain
|
Details | |
4.66 KB,
patch
|
Details | Diff | Splinter Review |
I get these errors when trying to parse a ics file into events, and put those events in a memory calendar: JS engine warning: 2 atoms remain after destroying the JSRuntime. These atoms may point to freed memory. Things reachable through them have not been finalized. JS engine warning: leaking GC root 'XPCVariant::mJSVal' at 0x8147e4c JS engine warning: 1 GC root remains after destroying the JSRuntime. This root may point to freed memory. Objects reachable through it have not been finalized. i see the first error all the time, but the seconds seems to be more interesting
Reporter | ||
Comment 1•20 years ago
|
||
Reporter | ||
Comment 2•20 years ago
|
||
Using this testcase, i get warnings about leaks. But when i remove the rrule, the warnings are gone.
Reporter | ||
Comment 3•20 years ago
|
||
If I remove the ref from calItemBase to the parent, the leaks are gone. There is a circular reference: the calendar has a ref to the events, and the events back to the calendar.
I propose making the link back to the parent be a weak ref (internally to calEvent; we would QIReferent and pass back a strong ref to callers, or else null, as we currently do).
Assignee: shaver → vladimir
Reporter | ||
Comment 5•20 years ago
|
||
The changes in comment 3 won't fix testcase 2 (rrule based leaks), but i guess that has the same kind of problem (circular ref between calRecurrenceInfo and calItemBase)
Assignee: vladimir → nobody
Assignee | ||
Comment 6•17 years ago
|
||
I suspect that native wrappers (+circular references) are the problem, too, thus spidermonkey doesn't gc those objects. This patch evaluates to get rid of them by storing the "wrappedJSObject"s being passed items/calendars only. This fixes the unit test warnings, but doesn't make bug 367456 any better. mvl, do you see any missing code pieces?
Updated•17 years ago
|
Flags: wanted-calendar0.8?
Comment 7•17 years ago
|
||
Daniel, is there a reason why you did not request review? from mvl?
Updated•17 years ago
|
Flags: wanted-calendar0.8? → wanted-calendar0.8+
Reporter | ||
Comment 8•17 years ago
|
||
Comment on attachment 284953 [details] [diff] [review] getting rid of wrappers > var event = Components.classes["@mozilla.org/calendar/event;1"] > .createInstance(Components.interfaces.calIEvent); >- item = event; >+ item = event.wrappedJSObject; I was sure I already posted my comments, but it seems I remembered wrong. So here it my comment: I don't like this code pattern. It totally breaks xpcom. What if calIEvent is implemented in C++? It would not work at all. I don't have huge problems with forcing the calIEvent implementation to be written in javascript, but then we should not use the xpcom way to create an instance. But I would prefer to not force things like that, and stay more general. And, if we get rid of the wrappers, I don't think that this would be fixed. The error might go away, but I think there are still the same circular references, and thus leaks. They are just not detected by xpconnect, because that's no longer in the loop.
Assignee | ||
Comment 9•17 years ago
|
||
(In reply to comment #8) > I was sure I already posted my comments, but it seems I remembered wrong. So ... Yes, we've already chatted about this some months ago. The mentioned patch was just a proof of concept that those js wrappers actually cause some leaks. After unwrapping those references, the leak warnings went away. A real fix of the problem will probably make use of weak references. > And, if we get rid of the wrappers, I don't think that this would be fixed. The > error might go away, but I think there are still the same circular references, > and thus leaks. They are just not detected by xpconnect, because that's no > longer in the loop. Circular references per se are not provoking leaks if gc could properly track all objects that take part. Since js/native wrappers hinder the engine from doing so, we could use weak references here. There might be more leaks, but we this shouldn't hinder us from fixing the known ones.
What's the bug number for the underlying leak problem? It doesn't sound like this pattern should cause leaks, so if it is please file an XPConnect bug with test case.
Reporter | ||
Comment 11•16 years ago
|
||
I suspect that the cause of the leaks here is that there are also C++ components. calRecurrenceInfo has a list of calRecurrenceRule and calReucrrenceDate, which are c++. There might be some cycle there, with closures, refcounting and all that.
Assignee | ||
Updated•16 years ago
|
Flags: wanted-calendar0.8+ → wanted-calendar0.9+
Assignee | ||
Comment 12•16 years ago
|
||
The test case has been fixed with checkins for bug 423172: The leaking gc roots have vanished (though 5 atoms remain).
Status: NEW → RESOLVED
Closed: 16 years ago
Depends on: 423172
Resolution: --- → FIXED
Target Milestone: --- → 0.9
Updated•16 years ago
|
Assignee: nobody → daniel.boelzle
You need to log in
before you can comment on or make changes to this bug.
Description
•