Vaadin 14 - Memory leak ?

Hi,

I’m on vaadin 14.0.2.
I simplified my app at its maximum :

@Route("")
public class MainLayout extends Div {
    public MainLayout() {
    }
}

Each time i refresh my browser page a new com.vaadin.flow.component.UI and a new MainLayout are created. Ok cause I don’t have @PreserveOnRefresh.
But old instances stay in memory. Only me with this problem ?

Obejcts referencing one UI:

com.vaadin.flow.component.PushConfigurationImpl@0xc1814288 (32 bytes) : field ui
com.vaadin.flow.internal.nodefeature.ComponentMapping@0xc1814080 (32 bytes) : field component
com.vaadin.flow.component.page.History@0xc1814258 (32 bytes) : field ui
com.vaadin.flow.component.internal.UIInternals@0xc1813c30 (192 bytes) : field ui
java.util.HashMap$Node@0xc18142a0 (44 bytes) : field value
com.vaadin.flow.router.Router$$Lambda$68@0xc1814270 (32 bytes) : field arg$2
com.vaadin.flow.component.page.Page@0xc1814240 (40 bytes) : field ui

Thanks,
Sylvain

There is an another discussion about it here: https://vaadin.com/forum/thread/17810577

The same problem is behind this issue as well: https://github.com/vaadin/spring/issues/473

I’m not sure it’s related.
Other topics is about objects instanciations. My problem is about objects that stay in memory.
I set the param heartbeatInterval to 30 seconds. Sometimes some UI are garbage collected but never all of them…

Or at least not in time… In fact when is deleted an UI exactly? after 1 miss heartbeat ?

Hi Sylvain. UIs are cleaned up after three missed hearbeats and the default interval is 5 minutes. So that makes it 15 minutes of inactivity until the UI is cleaned. All the remaining UIs are cleaned up once the session is expired. Unfortunately there is no API in the browser yet to be able to detect the user closing the browser window/tab reliably, though the beacon API might be now relevant once we drop support for IE11 starting from V15 (https://developer.mozilla.org/en-US/docs/Web/API/Beacon_API)

Here is some more details on how the lifecycle of the UI works https://vaadin.com/docs/v14/flow/advanced/tutorial-application-lifecycle.html#application.lifecycle.ui-expiration