Question of memory

A little question: I have the main layout (as primary) containing a menu bar and a secondary layout. When I click an item in the menu I remove all components of the secondary layout and I instantiate an object from a class that builds an UI inside the secondary layout. So my question is: removing all components of the layout (vl.removeallcomponents), I also free the memory? Or I’m clogging up the memory? Thanks…

As long as you don’t keep other references to the removed components e.g. via listeners, the memory will be freed as in any Java application - there is nothing Vaadin specific about that.

Note that listeners between components in the set of removed components are not a problem, nor are other listeners that do not contain an (implicit or explicit) reference to any of the removed components. It is easy to create an “invisible” reference to the containing object without noticing it by using a non-static nested class such as an anonymous class, though.

Thank you! :slight_smile: