I am creating a new presenter like so:
new MyPresenter(new MyView());
It registers some event handlers and binds to the view and such. Eventually, I might "close" that view so that it is no longer rendered by the browser. I am not maintaining a reference to this instance of MyPresenter
anywhere.
In the Google forums on this topic, the conventional response is to "set your references to null" and then don't worry about it. Unlike in Javascript, I can't just say this = null;
in Java for obvious reasons. But in Javascript, it's very easy to null out object references that I know will no longer be used.
My question: How can I tell if this presenter has been garbage collected since I don't maintain a reference to it? It very clearly exists. Should I have faith that GWT and JS will take care of this? Or do I need to maintain my own reference to MyPresenter
so that I can manually null
it when I'm done with it?