Thanks for the fast reply :-).

John Bandhauer wrote:
>
> The thing holding the wrapper and thus your native object alive is the
> JS engine. The JSObject that you get from GetJSObject and return via vp
> is apparently reachable from some root object in JS (or JS garbage
> collection is not occurring?).

This is the javascript code:

function test() {
    var myCamera = obj._myRenderer.getCamera();
    var myPosition = myCamera.position;
}

As you can see, we're not running in the browser - this is standalone xpconnect for a 3d engine. We're calling JS_GC regularly and myPosition doesn't get destroyed. myCamera - which we're getting using standard idl-based xpcom interfaces - is correctly destroyed when gc happens.


>> We're also unsure about what to pass as scope.
>
> Passing the obj you receive as a param to your GetProperty should be fine.
>
> FWIW... The 'scope' here is used as a scheme to partition wrapper
> spaces.


Ah... that clears a lot up. We were assuming that the scope was used to find a gc root for the return value.

>> Since we're returning a
>> value, the reference to that value should be gone when the stack frame
>> is discarded. How is this accomplished?
[...]
> Any JS object
> (and other sorts of JSGC objects) that is reachable by a root object in
> JS will continue to live.

My fault for being unclear, so I'll restate the question in a completely different way: Am I correct in assuming that the initial root object for the return value should be rval in the current stack frame? Does WrapNative root the return value? How does it know what to use as root? Or is the return value rooted after we return from GetProperty?

> Hope this helps you figure out what is going on.

Yup - we're getting there.

Uli




Reply via email to