On Tuesday, February 8, 2011 2:51:23 AM UTC+1, Y2i wrote:
>
> Thomas (and GWT team)
>
> If a view is a singleton (as recommended by MVP), are there potential 
> memory leaks with this approach?
>

Yes, but not related to the Editor framework (only to the fact that a 
singleton will still exist until the page is unloaded, even if you no longer 
use it; this means that the singleton approach might not be appropriate for 
all views: if a view is displayed early but you know it has little to no 
chance of being displayed later –e.g. a "welcome" or "what's new" screen– it 
might be better to not make it a singleton: you'll "pay" again for building 
a new one when needed, but on the other hand you'll free memory).
 

> When a second driver is created and initialized, does the first driver 
> become completely detached from the view/editor?
>

A driver (and its delegates) is never attached to the view/editors. The 
delegates can be (if an editor implements HasEditorDelegate), as well as the 
EditorChain (used by CompositeEditor-s), but if your editors don't retain 
references on those instances, there won't be memory leaks (the next driver 
will pass its own instances).

Note that in 2.1.x and 2.2.x there's actually a "leak" if you re-use the 
same driver for several edit() with different objects (the DelegateMap is 
created once and never cleared; EditorDelegate-s are created for each call 
to edit() and put in the map, associated with the edited object).
Looking at the code in trunk (GWT 2.3), the EditorDelegate-s are created 
once on initialize(), and the DelegateMap is only used in 
setViolations/setConstraintViolations; so it seems to me like there's no 
longer such a potential leak.

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

Reply via email to