Closed
Bug 25911
Opened 25 years ago
Closed 25 years ago
Leaking JSContexts
Categories
(Core :: XPConnect, defect, P3)
Core
XPConnect
Tracking
()
RESOLVED
FIXED
People
(Reporter: beard, Assigned: jband_mozilla)
References
()
Details
(Keywords: memory-leak)
Attachments
(2 files)
You are creating XPCContext objects in XPCJSRuntime::SyncXPCContextList(), and
adding them to a JSContext2XPCContextMap (XPCJSRuntime::mContextMap), but
evidently not cleaning up the contents of the map in
XPCJSRuntime::~XPCJSRuntime().
Reporter | ||
Comment 1•25 years ago
|
||
Reporter | ||
Comment 2•25 years ago
|
||
Assignee | ||
Comment 3•25 years ago
|
||
No.
The management of XPCContext objects is working correctly. SyncXPCContextList
uses KillDeadContextsCB which deletes unneeded XPCContext objects an removed
them from the hashtable using:
// this XPCContext represents a dead JSContext - delete it
delete xpcc;
return HT_ENUMERATE_REMOVE;
This can be verified by running a xpconnect in an embedding that does not leak
the underlying JSContexts; e.g. xpcshell running xpctest_echo.js
No, the real problem is that mozilla.exe leaks JSContexts and/or does not notify
xpconnect to resync in all places where JSContexts are deleted.
I have leak detection code in XPCJSRuntime::~XPCJSRuntime() I just added a block
to iterate all JSContexts and report the count:
#ifdef DEBUG_jband
{
// count the total JSContexts in use
JSContext* iter = nsnull;
int count = 0;
while(JS_ContextIterator(mJSRuntime, &iter))
count ++;
printf("deleting XPCJSRuntime with %d total live JSContexts\n", count);
}
#endif
Running the checked in bloaty tests I see:
deleting XPCJSRuntime with 3 total live JSContexts
deleting XPCJSRuntime with 3 live JSContexts known by xpconnect
deleting XPCJSRuntime with 2 live xpcwrappednativeclasses
...and...
the report lines show that one nsJSContext is leaked.
There must be other JSContexts created in the system.
I can explore further.
[changing bug title from...
[MLK] Leaking XPCContexts
...to...
[MLK] Leaking JSContexts
Status: NEW → ASSIGNED
Summary: [MLK] Leaking XPCContexts → [MLK] Leaking JSContexts
Reporter | ||
Comment 4•25 years ago
|
||
I only report what I see. My attachment shows that there's an unaccounted for
XPCContext, that ISN'T referred to by any other leaked object. This is a GC-based
leak detector, so if the object were being referenced by any other leaked object,
I would see it.
Assignee | ||
Comment 5•25 years ago
|
||
Sure. The xpconnect shutdown code is whacking the map that references the
XPCContext objects and yes I agree that when the map gets whacked there is no
reason to not delete any remaining XPCContexts. I can add that code. This is a
shutdown only issue. XPCContext objects correctly come and go during the life of
the app.
Still, the underlying problem is really that we are leaking JSContexts.
Assignee | ||
Comment 6•25 years ago
|
||
These JSContexts are leaked because nsJSContexts are leaked by the cycle
described in http://bugzilla.mozilla.org/show_bug.cgi?id=28570
Depends on: 28570
Comment 7•25 years ago
|
||
Is this fixed then?
Assignee | ||
Comment 8•25 years ago
|
||
I believe this is fixed.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•