Subj : Re: [spidermonkey] JS_CallFunction in Finalize To : netscape.public.mozilla.jseng From : Brendan Eich Date : Fri Aug 26 2005 03:04 pm Brendan Eich wrote: > Consider DOM window objects. If I write , I shouldn't leak, but the opened window should be visually > closed when the user clicks on its close [x] box or whatever widget is > used by the desktop/window-manager/OS for closing windows, and at *that* > point, "onunload" or a hypothetical "onclose" event handler should run > -- *not* later when the window object is finalized by the GC. Now consider In a sound DOM implementation, the alert succeeds, does not crash, etc., because w refers to a live object -- the GC can't declare it garbage until the w variable that roots it goes away (when the window loading this script's document is itself closed, or the window loads another doc displacing this one and clearing its properties). This means that such objects as DOM windows and your Modules can be "closed" but "alive" -- they need to be in a state that's not yet finalized, but not "open" or useful. Such closed objects may be poison pills (touching them to read or write property values crashes the program, or throws unwanted or even uncatchable exceptions) in some broken JS embeddings, but they should not be. Ideally your users could even discover that they are closed, and cope. /be .