Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JS_AddNamedRoot

42 views
Skip to first unread message

Chris Dillman

unread,
Nov 17, 2006, 2:25:18 AM11/17/06
to dev-tech-...@lists.mozilla.org

After read the docs and lots of examples.

Im really not sure where and or when I would need to call JS_AddNamedRoot
in my C code.

Can someone clearly explain why I would need to use it?


--
---------------------------------------------

Email: chr...@plaidworld.com
iChat / AIM: crack...@mac.com

Plaid World Studios http://www.plaidworld.com

Sebastien Marinier

unread,
Nov 17, 2006, 8:41:58 AM11/17/06
to
Hy,

You need to call JS_AddNamedRoot when your object is created by your
Code, and is not linked or owned by any other JS object.

This might happen:

1) If you create JS object from your code, and you're calling the
interpreter, or a function.

2) If you create multiple objects from your code, before they're
"linked" to their parent object.

The most frequent use is when you're creating an array (JS_NewArray),
and you fill the member of your array with JS created object. You MUST
call JS_AddNamedRoot in that case.

In fact, you have to keep in mind, that mots allocation calls you make
to the JS library might call the gargage collector if there's not enough
memory in the GC. The garbage collector will free all "unlinked" object
(not owned by any parent object)... That why you need temporarily to
call JS_AddNamedRoot.


Chris Dillman a écrit :


>
> After read the docs and lots of examples.
>
> Im really not sure where and or when I would need to call JS_AddNamedRoot
> in my C code.
>
> Can someone clearly explain why I would need to use it?
>
>
>
>

--
------------------
Sébastien Marinier

0 new messages