Wednesday, March 30, 2011

MVP + Handlers + Carelessness = Memory Leak ?

Hallo,

I'm not sure how GWT handles this, so I want to evaluate a short
example scenario for memory leaks. Suppose I write my own handler

public Interface BlubbHandler {
void onBlubb(BlubbEvent event);
}

have my presenter

public class MyPresenter {
private final MyView view;
private final StringContainer justToBeFinal;

@Inject
public MyPresenter(MyView view) {
this.view = view;
view.addBlubbHandler(new BlubbHandler(){
justToBeFinal.setText("BLUBB");
});
}
}

and now my Widget is disposed. Will the memory it uses ever be freed?
Or does the reference to view prevent view from being disposed, and
the reference of view's BlubbHandler to justToBeFinal prevent
MyPresenter to be disposed?
I'm not even sure, how it would be in Java, but I think in Java this
would cause a memory leak, wouldn't it?
So do I have to add a dispose() method to pesenter, that must be
called to null out the BlubbHandlers of view?
And how is this handled with GWT's own event system? Or with event
systems constructed on top of GWTs own one, using SimpleEventBus and
extending / implementing GWT's classes?

Anyone who is more versatile in these matters and can help me would be
very appreciated :-) I don't want to find out after lines and lines of
code, that I'm memory leaking like stupid...
Greetz,
Peter

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment