Subj : How to remove dynamically created properties To : netscape.public.mozilla.jseng From : Lukas Ramach Date : Mon Nov 08 2004 01:40 pm Hello! I'm trying to get rid of memory leaks in my application. I dynamically set XPCOM objects as properties in javascripts and delete them again. The objects are addrefed when defined as property but never removed any more. *) I set properties doing the following: // pPropertyObject is an nsISupports* nsCOMPtr m_pXpc; m_pXpc = do_GetService (nsIXPConnect::GetCID(), &nsr); // WrapNative addrefs by 2 nsCOMPtr pHolder; nsr = m_pXpc->WrapNative (m_pContext, m_pGlobalObject, pPropertyObject, *pPropertyInterfaceID, getter_AddRefs (pHolder)); JSObject* pJSObject; pHolder->GetJSObject(&pJSObject); jsval aJSValue = OBJECT_TO_JSVAL(pJSObject); nsAString::const_iterator cit; JS_SetUCProperty (m_pContext, m_pGlobalObject, sPropertyName.BeginReading (cit).start (), sPropertyName.Length(), pPropertyValue)); *) and I remove it again calling: JS_DeleteUCProperty2 (m_pContext, m_pGlobalObject, sPropertyName.BeginReading (cit).start(), sPropertyName.Length(), &aJSValue)); Am I doing anything wrong? Thanks, Lukas .