what is detach method? usage?

detach method how do i implement in vaadin application. is it use for garbage collect for application? or any usage in this method.

for example:

VerticalLayout layout = null; layout.detach(); is it correct?


You should never need to call it directly yourself - the framework (more accurately, by layouts and other component containers) calls it when you remove a component from a layout.

You may occasionally want to override it in your classes to perform additional actions when the component is detached. When overriding it, make sure super.detach() is also called. Also note that the method is not called when the component is removed indirectly or e.g. the session expires, so you should not rely on it for clean-up of background threads or connections to external systems and similar tasks.

How to help garbage collection is quite a complex topic in general, not just in Vaadin applications. Explicit references to big parts of UI or data as well as listeners and implicit references in the form of the “hidden” containing class reference in anonymous classes are often responsible for holding more than necessary in memory, but there are no easy rules to find and address such problematic locations in each application.


I have a application where i am using dojo bullet graphs which are added to loading panels. At a particalar interval of time new set of bullet graphs will be created with fresh data. Parallely these loading panels will replace old bullet graphs with the new created once using relacecomponent() method.

Now the issue is that on the application server I see that bullet graphs are taking significant amount of heap space. I am suspecting that my old bullet grpahs are not being garbage collected. How can i make sure these graphs are cleaned up after loadingpanel replaceComponent method is called?

Thanks in advance.