Compare Revisions

Interfacing with the XPCOM cycle collector

Change Revisions

Revision 424067:

Revision 424067 by deian on

Revision 426179:

Revision 426179 by mikeaich on

Title:
Interfacing with the XPCOM cycle collector
Interfacing with the XPCOM cycle collector
Slug:
Interfacing_with_the_XPCOM_cycle_collector
Interfacing_with_the_XPCOM_cycle_collector
Tags:
"XPCOM", "Firefox 3"
"XPCOM", "Firefox 3"
Content:

Revision 424067
Revision 426179
n103      If your class has a field of type <code>JSObject</code> youn103      If your class has a field of type <code>JSObject</code> you
> nede to tell the cycle collector about it, using <a href="https:> need to tell the cycle collector about it; using <a href="https:
>//mxr.mozilla.org/mozilla-central/ident?i=JS_AddNamedObjectRoot" >//mxr.mozilla.org/mozilla-central/ident?i=JS_AddNamedObjectRoot" 
>title="https://mxr.mozilla.org/mozilla-central/ident?i=JS_AddName>title="https://mxr.mozilla.org/mozilla-central/ident?i=JS_AddName
>dObjectRoot">JS_AddNamedRoot</a> in a class method and <a href="h>dObjectRoot">JS_AddNamedRoot</a> in a class method and <a href="h
>ttps://mxr.mozilla.org/mozilla-central/ident?i=JS_RemoveObjectRoo>ttps://mxr.mozilla.org/mozilla-central/ident?i=JS_RemoveObjectRoo
>t&amp;tree=mozilla-central&amp;filter=" title="https://mxr.mozill>t&amp;tree=mozilla-central&amp;filter=" title="https://mxr.mozill
>a.org/mozilla-central/ident?i=JS_RemoveObjectRoot&amp;tree=mozill>a.org/mozilla-central/ident?i=JS_RemoveObjectRoot&amp;tree=mozill
>a-central&amp;filter=">JS_RemoveObjectRoot</a> in your destructor>a-central&amp;filter=">JS_RemoveObjectRoot</a> in your destructor
> is not the correct approach. The approach you should take instea> is not the correct approach. The approach you should take instea
>d is as follows.>d is as follows.
t167      Recall (or see <a href="/en-US/docs/SpiderMonkey/JSAPI_Refet167      Recall (or see <a href="/en-US/docs/SpiderMonkey/JSAPI_Refe
>rence/Jsval" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/Jsva>rence/Jsval" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/Jsva
>l">here</a>) that a <code>JS::Value</code> may refernece a string>l">here</a>) that a <code>JS::Value</code> may reference a string
> or object and is subject to GC. Hence, we need to tell the cycle> or object and is subject to GC. Hence, we need to tell the cycle
> collector about any such member variables. This is the same as f> collector about any such member variables. This is the same as f
>or the <code>JSObject</code> case, but using the <code>NS_IMPL_CY>or the <code>JSObject</code> case, but using the <code>NS_IMPL_CY
>CLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK</code> macro:>CLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK</code> macro:

Back to History