Subj : System resource wrapping To : netscape.public.mozilla.jseng From : Matthew Mondor Date : Thu Feb 10 2005 07:09 am Hi, I have created a custom class with SpiderMonkey which needs to wrap a filedescriptor internally. When the object is constructed, it allocates necessary system resources, including opening a file and storing the filedescriptor. This data is stored in the private member of the object, and retreived by other related methods of that class. This seems to be working well so far, however I have been wondering: Since these objects hold a filedescriptor to an open file, and that there is a close() method which the caller uses at will to free that resource, is it possible for GC operation in some circumstances to call the finalizer function of that object inadvertantly? If so, I can close all resources in the finalizer, but wouldn't the user like magically loose it's object at times? Since this is sortof a user script controlled resource, unlike most temporary objects which can be discarded implicitely, these need to be discarded explicitely in general. Does this mean that I should use something like JS_AddRoot() to prevent any kind of inadvertent GC operation on them? I.E. is this a proper candidate to be added to the root. Thanks, Matt .