Automatic closing of top-level windows by Application

Hi!

We’re doing work to make “support for safe way of using the application from multiple windows without synchronization errors” work with our application. Our opinion is, that the Application class of the Toolkit should listen its top level windows for close events and remove them from the “windows” collection when they are closed. These windows cannot be accessed anymore (unless the user types the correct url with the random-generated window name in it) and are thus just taking memory.

What do you think, wouldn’t it be good to have this functionality directly in Toolkit?

Cheers,

Kai

Unfortunately case is not that simple. Any navigation away from the page causes a close-event. This includes reloading the page, web-links to the same page, back-button, entering url, … Automatic removal of windows from the application would break these.

On the other hand, adding close-event listener is really easy - when you are sure that you want to remove window from application just add a listener. Or you can even override the default Window.close().

If you are more concerned of memory leak, yes it leaks when window is somehow “closed” from the client-side (Joonas had workaround for one scenario).

But, closed windows and their references are garbage collected after session expires on your Servlet container / Application server.

Actually, it would be useful to get events for: “windows closed and it is most likely that the person will not open it again”. In practice this could be actual close of the browser-window, but not navigating away from the window - for a short period of time.

In theory we could have some kind of “server-side closed window grace-period” and then remove windows from the application after it. In practice I think that removing windows from the application when the session expires or when the application somehow knows that they are not needed anymore is enough.