Hi Viktor,

Am 17.08.2007 um 03:33 schrieb Ferenczi Viktor:

>> will all children's destructors be called when I call method  
>> "removeAll"
>> of the parent-widget?
>
> The removeAll method is implemented in the Parent class. The  
> removeAll method
> calls the remove method for each child widget. The remove method  
> only removes
> the widget from the parent (removes only the association between  
> them), but
> does not destroy it immediately.
>
> The object is freed and the destructor is called later during garbage
> collection if no reference left to the widget (Object), since it  
> becomes
> unaccessible from your code.
>
> However the object is not disposed if you keep reference(s) to the  
> object,
> which could cause memory leakage. Be aware of circular references (for
> example: parent->child->parent). Take a look at the destructor of  
> the Parent
> class in qooxdoo as an example of best practices.
>
> More information: http://qooxdoo.org/documentation/0.7/ 
> destructor_support

Regarding qooxdoo, your explanations are not quite correct. In  
principle, you are right - as soon as all references to an object  
disappear, the object can be garbage collected. However, a reference  
to (almost) every qooxdoo object is stored in a central qooxdoo  
object database. The purpose of this db is to call dispose() on every  
object when the page is unloaded (to give the objects a chance to cut  
off all references between JS and DOM objects, which would otherwise  
produce leaks in Internet Explorer).

Unfortunately, this means that there's _always_ at least one  
reference to any qooxdoo object until you call dispose() on it. The  
dispose() call not only gives the object a chance to clean up after  
itself, but also removes the reference to it from the object db. The  
object can only be garbage collected after this call.

There are some actions that call dispose() automatically - for  
example, disposing a widget also disposes all of its children.  
However, the removeAll() method of a widget _doesn't_ dispose the  
children, so you have to do it manually (or write a utility method  
that you can use instead of removeAll()).

Regards,

   Andreas


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to