I prefer to head off managing the handler memory leaks by holding the
registrations in a View data member that gets automatically released as the
view is garbage collected.
The sencha gxt library makes it easy to capture and track registrations
using the GroupingHandlerRegistration. It should be straightforward to
rewrap this functionality in a custom container.
class MyView extends Composite {
/**
* prevent leaks from handlers
*/
protected GroupingHandlerRegistration handlerRegistrations = new
GroupingHandlerRegistration();
public initWidget() {
// always capture handler regs as they are created.
handlerRegistrations.add(this.myButton
.addSelectHandler(....);
}
}
On Wed, Jun 19, 2013 at 8:37 AM, Nicholas <[email protected]> wrote:
> Hi !
>
> We are encountering some memory leaks issues (mainly in IE of course) in
> our application that is based on the MVP pattern. After a deep code
> analysis we discovered that:
>
> - We forgot to remove some handlers (using removeHandler() method from
> HandlerRegistration) on some custom widget we have created.
>
> - Some of the core GWT widget we use (such as DateBox or DialogBox) have
> some handler registrations that are never removed using the previous method.
>
> - Some of the handlers added in the bind() method of some presenters were
> also never removed, from the global EventBus or even on some widgets
>
> After reading some interesting documentation and other developpers
> experiences such as
> https://developers.google.com/web-toolkit/articles/dom_events_memory_leaks_and_youor
> http://www.draconianoverlord.com/2010/11/23/gwt-handlers.html it seems
> that removing handlers in the onUnload() method of a Widget seems to be
> pointless in most cases, as GWT already manage to do that ... and that
> would explain why some of the core GWT widgets don't even care to remove
> those handlers ...
>
> Does it worth going through each component on which we didn't unregistered
> some handlers in the onUnload method and unregister those handlers or is it
> just pointless, meaning that we should rather focus on the application part
> (EventBus, Presenters etc ...)?
>
> In a more general way, is there a way to detect (unit tests or integration
> tests) that all listeners of an event source are actually removed when they
> should have ?
>
> Thanks !
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
-- A. Stevko
===========
"If everything seems under control, you're just not going fast enough." M.
Andretti
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.