0

Found in GWT Release:

GWT - 2.4.0

Encountered on OS / Browser :

Windows 7 with IE9

Detailed description (please be as specific as possible):

Out Of Heap exception occurred after left GWT App to run overnight, Diagnosis with MemoryAnalyzer, found that upon crash there are 1.6 million instance of com.google.gwt.http.client.RequestBuilder , each size exactly at 1208 bytes.

Further checking reveal to me that those request are GWT Action call to server to poll current server health status. poll trigger by com.google.gwt.user.client.Timer every 1 sec

Shortest code snippet which demonstrates issue:

@Inject
public MainPresenter(final EventBus eventBus, final MyView view,
        final MyProxy proxy, PlaceManager placeManager,
        final DispatchAsync dispatcher) {
    super(eventBus, view, proxy);
    this.placeManager = placeManager;
    this.dispatcher = dispatcher;
    getView().setUiHandlers(this);

    setupSeverHealthQuerier(dispatcher);
}

private void setupSeverHealthQuerier(final DispatchAsync dispatcher) {
    int delayInSec = UserPreference.HealthCheckInterval;

    serverHealthChecker = new Timer() {

        @Override
        public void run() {
            dispatcher.execute(new GetServerHealth(ServerName.ReplayServerGTU),
                    new AsyncCallback<GetServerHealthResult>() {

                        @Override
                        public void onFailure(Throwable caught) {
                            caught.printStackTrace();
                        }

                        @Override
                        public void onSuccess(GetServerHealthResult result) {
                            getView().setServerHealthPic(result.getHealth());
                        }
                    });

        }
    };
    serverHealthChecker.scheduleRepeating(delayInSec * 1000);
}

Here is the Heap Report:

https://i.stack.imgur.com/C2qJy.png

  • thanks for the 10 reputation-to-post-image rule
Ben.Yan
  • 118
  • 4
  • 13
  • oops, So my question is why those request builder are still in heap left to build up, and how can i solve the memory leak problem. Thanks for the help in advance – Ben.Yan Jun 01 '12 at 10:55

1 Answers1

3

They're not RequestBuilder instances, but instances of an anonymous inner class, which can only be the underlying XMLHttpRequest's ReadyStateChangeHandler.

Given that you left your DevMode session open all the night, could you computer have gone to standby mode (sorry, I don't know the exact term in English) and shut down the networking?
Given that you appear to be using IE, and IE never times out the requests, it could really be that requests have been made but never reached the network and never timed out, so the classes are kept in memory.

Just an idea.

I'd also bet this is only an issue in DevMode, and with IE.
This is a very unusual use of DevMode, so I'd hardly call it a bug. It's also not worth fixing as the GWT team is working on a new SuperDevMode that would no longer require a browser plugin but instead always compile the code to JS, on-the-fly.


Try scheduling the timer again from the onFailure and onSuccess instead of using `scheduleRepeating. See also http://ejohn.org/blog/how-javascript-timers-work/

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • Hi Thomas, Thanks for replay to both of my ticket, the how-javascript-timers-work/ website is very detailed and helpful. – Ben.Yan Jun 01 '12 at 15:51
  • I will refactor the timer code and give it a try, interesting thing is i been capture heap report during normal GWT execution, computer is keep alive, still the retained size of XMLHttpRequest is slowly build up. – Ben.Yan Jun 01 '12 at 15:55