Wednesday, March 30, 2011

MVP + Handlers + Carelessness = Memory Leak ?


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;

public MyPresenter(MyView view) {
this.view = view;
view.addBlubbHandler(new BlubbHandler(){

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...

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment