Vaadin keep the model in memory?

I usingo vaadin with springboot and wanna to know If the vaadin keep the model in memory. beucase I create a lot of models in my project,


When my user enter in my Cliente view I fill a combobox with this models. but in jvm the model only grow-up, even though I’m running the GC the model is not released


The answer is yes and no, I’ll summarize why.

ComboBox and Grid use by default ListDataProvider, which is in-memory DataProvider. If your data model is big, it is not adviced to use the default data provider, since the session footprint potentially will grow oversized.

Therefore it is also possible use lazy data providers. Lazy data provider means a data provider which has custom callbacks to fetch data from database as defined by you. This reduces the memory footprint of your application.

For details how to implement one, check our documentation here:, especially the chapter “Lazy Loading Data to a Listing”

We have published also a good blog post, with example app here:

But my problem are when my User leave the view that have a combobox with one of those models, the vaadin don’t release the memory (he keep the models) and if my user back to that view the memory duplicates

I understand now, you are not actually talking about data model, but does Vaadin keep Session or UI in the memory. If application is implemented correctly, Session and UI are not kept in the memory. They should be garbage collected by JVM normally. What is not cleaned are threads started by your application. So application should take care of ensuring that there is no runnaway threads, no references to UI or Session left hanging in threads etc. Those can prevent JVM to garbage collect Sessions and UI instances. Use either UI’s detach() method or sessionDestroyListener as hooks to clean threads etc.

Note, it can take some time before Sessions are GC’d (see: If your app consumes memory, you can make clean up happen quicker in various ways. Set session timeout shorter in container. You can set heartbeat interval as short as possible, and set closeIdleSessions=true in your servlet config, something like this:

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyUI.class, heartbeatInterval=5, closeIdleSessions=true, widgetset = "org.myapp.AppWidgetSet")
public static class Servlet extends VaadinServlet {

In special cases more tricks may be needed. Then e.g. can be useful.