How can you tell that a JavaScript's Object has been destructed.
Is there a dtor function in JS?
Is the garbage collection working well in JS ?
destructor in JavaScript
-
- Posts: 397
- Joined: February 24th, 2008, 6:27 am
- Location: Moscow, Russia
Re: destructor in JavaScript
AFAIK there is no such a function. Garbage collection works well so you don't normally need any destructor.
But if you really need the destructor (for example, you want logging construction/destruction) you can probably use link to the instance of binary (C++) XPCOM-component. If it's the only link to this instance, when JS object will be GCed, component will be freed and its destructor will be called. Then you'll probably need some JS callback function to be called from this binary destructor so be afraid of cycles which may be not GCed. Is there any already existing debug API for this??? What about Venkman?
Also there are Leak Tools that may be more helpful for you.
But if you really need the destructor (for example, you want logging construction/destruction) you can probably use link to the instance of binary (C++) XPCOM-component. If it's the only link to this instance, when JS object will be GCed, component will be freed and its destructor will be called. Then you'll probably need some JS callback function to be called from this binary destructor so be afraid of cycles which may be not GCed. Is there any already existing debug API for this??? What about Venkman?
Also there are Leak Tools that may be more helpful for you.
-
- Posts: 9
- Joined: October 18th, 2008, 11:22 am
Re: destructor in JavaScript
I added the 'Leak Monitor' and found some observers leaking.
I only needed to be sure that I didn't have any thing left.
/Thanks
I only needed to be sure that I didn't have any thing left.
/Thanks