I have a Vaadin application that uses multitab approach. Application.getWindow(String name)
is overriden in the manner that if super.getWindow(name)
is not found, it creates and adds a new window to an application . All windows have Window.CloseListener
's which print message to output. Also I see moments of creation and destroying of windows - constructor and finalize()
both print messages to console too.
When I refresh same browser tab a new window is created and I see Window.CloseListener
's message in console and none of messages from finalize()
methods. If I add a singleton AtomicLong which counts instances (add in constructor, dec in finalize()
), I see growing number of instances (on those refreshes) which is not decrementing with time.
It seems like Vaadin stores closed windows somehow. I also jmap
'ed an application and opened heap file in Eclipse MAT. MAT shows that one of components of closed window, UriFragmentUtility
, is referenced with a chain: Application
-> WebApplicationContext
-> CommuncationManager
-> (through paintableMap) UriFragmentUtility
(see image attached).
How can I destroy closed windows to prevent memory leaks?
Update
I have found that in the code windows are only added to Vaadin Application
and are not deleted. After adding Application.removeWindow()
nothing has changed related to refreshing same tab.