GWT does a great job of letting us avoid the memory leak pitfalls that
often occur in poor browser, but I think I may have found a case that
GWT does not handle and I'm not sure why.
We have an application where we mark a particular page as visited by a
user when they open the page and when they leave the page. To do the
mark when they leave the page, we have added an onWindowClosed
listener that gets called and which makes an RPC call to the server.
I have discovered that this RPC call is causing a cross-page memory
leak. That is if you simply repeatedly hit refresh in the browser
(calling onWindowClosed each time) we are leaking 5 megabytes of
memory on each click. If I comment out the RPC call, the leak goes
away.
The method looks like this:
public void onWindowClosed() {
UserPreferencesServiceAsync serviceAsync =
(UserPreferencesServiceAsync)GWT.create(UserPreferencesService.class);
((ServiceDefTarget)serviceAsync).setServiceEntryPoint("/scr/
UserPreferencesService");
UserPreferencesService.App.getInstance().markProcessViewed(new
AsyncCallbackAdapter<Void>());
super.onWindowClosed();
}
The GWT.create itself is not the culprit since I can leave that bit in
and just remove the RPC call and there is no leak. I'm guessing some
part of GWT or the browser has to hold on memory in order to handle
the response from the server which could return after the page is
gone. I will point out that we don't care about the response from the
server.
Does anyone have any ideas as to what would cause this or how to fix
it? I haven't tried it yet, but I'm going to try using a
RequestBuilder and just executing an old-fashioned Servlet call
instead of an RPC call.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---