RootPanel.detachNow(Widget) method should be called before removing a  
wrapped widget from DOM to prevent your memory leak.

I believe that this method is documented in every widget that  
implements .wrap()

-jason


On Feb 10, 2009, at 10:55 AM, Nicolas Wetzel wrote:

> Hi all! ,
>
> The Widget.wrap()  API is very usefull to build widgets(fragments)   
> from html templates retrieved from server or bound with the java  
> widget class at the compilation time (generators).
> By this way,  the design (HTML+CSS) is entirely delagated to Web  
> Developpers, Java Gwt Developpers have to manage only with GWT  
> Widget which are in fact only controllers:
>
> Each controler pick up some html element by id left in its  
> corresponding template and "build" gwt widget (TextBox,Label etc...)  
> with the wrap API  to manage the (dynamic) behavior.
> No css gwt api is used, no Panel for composition is used.
>
> Everything works fine while the  widget fragment is attached to the  
> DOM (RootPanel) but there is a trouble :
>   If the widget fragment is detached its components (i e widgets  
> created with the wrap api)  are not garbaged because they don't have  
> any parent.
>   So there is a memory leak. The wrap method doesn't alow to link  
> the life cycle of the component to its logical parent i e the widget  
> parent. Here is the code of the wrap method :
>
> public static Label wrap(Element element) {
>     // Assert that the element is attached.
>     assert Document.get().getBody().isOrHasChild(element);
>
>     Label label = new Label(element);
>
>     // Mark it attached and remember it for cleanup.
>     label.onAttach();
>     RootPanel.detachOnWindowClose(label);
>
>     return label;
>   }
>
>
> By the call of "RootPanel.detachOnWindowClose(label);" the widget is  
> gabaged only when the main window is closed. It is  not very clean  
> if the fragment is garbaged. We reported this touble 
> http://code.google.com/p/google-web-toolkit/issues/detail?id=3113 
>      in the bug tracker few months ago but it still in the same  
> state .
>
>
>
>
>
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to