Hi,

we have xpcom components here that inherit from nsIXPCScriptable and
we've run into a situation where we can't seem to get rid of a memory
leak. Basically, we're returning an xpcom component from GetProperty:

NS_IMETHODIMP 
acXPCDynamicProperties::GetProperty
        (nsIXPConnectWrappedNative *wrapper, 
         JSContext * cx, JSObject * obj, jsval id, 
         jsval * vp, PRBool *_retval)
{    
    [...]

    scope= ???
    nsISupports * native = ...

    {
        nsCOMPtr<nsIXPConnectJSObjectHolder> holder;

        nsresult rv = getXPConnect()->WrapNative(cx, scope, native, 
                aIID, getter_AddRefs(holder));
        NS_ENSURE_SUCCESS(rv, rv);

        JSObject* obj = nsnull;
        rv = holder->GetJSObject(&obj);
        NS_ENSURE_SUCCESS(rv, rv);

        *vp = OBJECT_TO_JSVAL(obj);
    }
    [...]
}

On the native side, we seem to be reference counting correctly. In the
WrapNative() call, the reference count goes up by two - I have no way
of verifying that that is as intended.

We're also unsure about what to pass as scope. Since we're returning a
value, the reference to that value should be gone when the stack frame
is discarded. How is this accomplished?

Thanks for any help,

  Uli

Reply via email to