nsScriptNameSpaceManager leaks hashtable entries

RESOLVED FIXED in mozilla1.0

Status

()

RESOLVED FIXED
18 years ago
18 years ago

People

(Reporter: dbaron, Assigned: jst)

Tracking

({memory-leak})

Trunk
mozilla1.0
memory-leak
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [XPCDOM])

Running under the Boehm GC on Linux, I see a number of memory leaks from
allocations at lines 74 and 75 in dom/src/build/nsScriptNameSpaceManager.cpp.

A guess is that these are caused by adding to the hashtable twice with the same
key, which causes you to leak the old entry.  (This could also explain why it
only started showing up recently.)  I recommend using the hash alloc ops (which
will let you avoid the enumeration before calling PL_HashTableDestroy). 
However, you would have to also free the key when called with HT_FREE_VALUE --
and you need to double-check that that will work OK (I've never seen it done).

Although perhaps it's an error to be called twice with the same key, and you
should check for that instead...
Keywords: mlk
The leaks are coming from duplication in ContentScriptNameSet and
LayoutScriptNameSet.  This should probably be fixed at both places...
(Assignee)

Comment 2

18 years ago
I'll most likely end up rewriting this code when working on the XPConnected DOM.
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: PC → All
Whiteboard: [XPCDOM]
Target Milestone: --- → mozilla1.0
Component: DOM Other → DOM Level 1
Something seems to have started calling this function a bit more, so that it's
now showing up in the daily leak numbers at:

ftp://ftp.mozilla.org/pub/data/leaks/

The stack is:


PR_Malloc[/u/curt/boehm/cm/mozilla/dist/bin/libnspr4.so +0x000163A6]
RegisterGlobalName__24nsScriptNameSpaceManagerRC9nsAStringRC4nsIDT2i[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so
+0x0005C816]
AddNameSet__20ContentScriptNameSetP16nsIScriptContext[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x0027545F]
PopulateNameSpace__23nsScriptNameSetRegistryP16nsIScriptContext[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so
+0x0005C45F]
GetNameSpaceManager__11nsJSContextPP25nsIScriptNameSpaceManager[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so
+0x00063287]
nsGlobalResolve__9nsJSUtilsP9JSContextP8JSObjectlP14JSPropertySpec[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so
+0x0009244F]
NS_CreateScriptContext[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so +0x0006A668]
_js_LookupProperty[/u/curt/boehm/cm/mozilla/dist/bin/libmozjs.so +0x00060E28]
JS_DefinePropertyWithTinyId[/u/curt/boehm/cm/mozilla/dist/bin/libmozjs.so
+0x00015647]
JS_LookupProperty[/u/curt/boehm/cm/mozilla/dist/bin/libmozjs.so +0x00015DBF]
NS_InitHTMLDocumentClass[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so +0x000D1241]
NS_NewScriptHTMLDocument[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so +0x000D1463]
GetScriptObject__14nsHTMLDocumentP16nsIScriptContextPPv[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x00307839]
NS_NewScriptHTMLHtmlElement[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so
+0x000DA51F]
NewScriptElement__24nsDOMScriptObjectFactoryRC8nsStringP16nsIScriptContextP11nsISupportsT3PPv[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so
+0x0005AED9]
GetScriptObject__16nsGenericElementP16nsIScriptContextPPv[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x0045484F]
NS_NewScriptXULElement[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so +0x00110EC3]
NewScriptXULElement__24nsDOMScriptObjectFactoryRC8nsStringP16nsIScriptContextP11nsISupportsT3PPv[/u/curt/boehm/cm/mozilla/dist/bin/libjsdom.so
+0x0005B4A5]
GetScriptObject__12nsXULElementP16nsIScriptContextPPv[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x0037F5D0]
InitClass__12nsXBLBindingRC9nsCStringP16nsIScriptContextP11nsIDocumentPPvT4[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x003F0BFD]
InstallProperties__12nsXBLBinding[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x003EE721]
InstallProperties__12nsXBLBinding[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x003EE34A]
LoadBindings__12nsXBLServiceP10nsIContentRC9nsAStringiPP13nsIXBLBindingPi[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x00408998]
ConstructFrameInternal__21nsCSSFrameConstructorP12nsIPresShellP14nsIPresContextR23nsFrameConstructorStateP10nsIContentP8nsIFrameP7nsIAtomiP15nsIStyleContextR12nsFrameItemsi[/u/curt/boehm/cm/mozilla/dist/bin/components/libgklayout.so
+0x00209434]
ConstructFrame__21nsCSSFrameConstructorP12nsIPresShellP14nsIPresContextR23nsFrameConstructorStateP10nsIContentP8nsIFrameR12nsFrameItems[/u/curt/boehm/cm/mozilla/dist/bin/components/libgklayout.so
+0x00209286]
CreateAnonymousFrames__21nsCSSFrameConstructorP12nsIPresShellP14nsIPresContextR23nsFrameConstructorStateP10nsIContentP11nsIDocumentP8nsIFrameR12nsFrameItems[/u/curt/boehm/cm/mozilla/dist/bin/components/libgklayout.so
+0x002059F9]
BuildGfxScrollFrame__21nsCSSFrameConstructorP12nsIPresShellP14nsIPresContextR23nsFrameConstructorStateP10nsIContentP11nsIDocumentP8nsIFrameP15nsIStyleContextiRP8nsIFrameR12nsFrameItemsT6[/u/curt/boehm/cm/mozilla/dist/bin/components/libgklayout.so
+0x00207646]
BeginBuildingScrollFrame__21nsCSSFrameConstructorP12nsIPresShellP14nsIPresContextR23nsFrameConstructorStateP10nsIContentP15nsIStyleContextP8nsIFrameP7nsIAtomP11nsIDocumentiRP8nsIFrameRt8nsCOMPtr1Z15nsIStyleContextT10_T6[/u/curt/boehm/cm/mozilla/dist/bin/components/libgklayout.so
+0x0020719B]
ConstructRootFrame__21nsCSSFrameConstructorP12nsIPresShellP14nsIPresContextP10nsIContentRP8nsIFrame[/u/curt/boehm/cm/mozilla/dist/bin/components/libgklayout.so
+0x002020FA]
ConstructRootFrame__12StyleSetImplP14nsIPresContextP10nsIContentRP8nsIFrame[/u/curt/boehm/cm/mozilla/dist/bin/components/libgkcontent.so
+0x004883FD]
InitialReflow__9PresShellii[/u/curt/boehm/cm/mozilla/dist/bin/components/libgklayout.so
+0x00189F16]
etc...
(Assignee)

Comment 4

18 years ago
Fixed by the xpcdom landing.
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.