Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
object cleanup in vaadin
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.
one thing you could do is add DetachListeners - if they're being called, the components should be free for garbage collection.
Hope this helps,
But these DetachListeners will be only called after the session has ended and clean up is called. I need the objects to be avaiable for garbage collection with the GUI opened as well. Is there any other way to trigger components to be set free for garbage collection at runtime. Something like component = null; so that my heapspace is not eaten up when my GUI is opened.
Detach should be called when a component is removed from a Layout. If it's not, that's a bug.
In the forum https://vaadin.com/forum/#!/thread/1409950, its mentioned that the detach shouldnt be called explicitly for components.
If use of detach is valid on components, then how can it be used in my use case?
VerticalLayout.replaceComponent( new graph object);
VerticalLayout. detach(old graph object);
In which case , I need to store the old graph objects for detaching it to the rendering layout.
replaceComponent itself should take care of it. Like the forum post says, you shouldn't need to call detach manually. Are you sure both components are not on the Layout? If that's the case, replaceComponent just switches the order, the old component is not removed.