What is the proper way to remove a dockable?

Hi!
I’ve been trying to remove/unregister a DefaultSingleCDockable that has been previously added to a CControl.

This is what I do:


// initializing
CControl dockControl =  ... ;
gridArea = dockControl.createGridArea("grid");
grid = new CGrid(dockControl);
DefaultSingleCDockable dockable = ...;
// when I add it to the dock control:
dockControl.add(dockable);
grid.add(0, 0, 1, 1, dockable);
gridArea.deploy(grid);

// later when I want to remove it:
dockControl.removeSingleDockable(dockable.getUniqueId());

The dockable is removed but the tab stills show, now without a close button. The component that has been added to the dockable I’m trying to remove is never garbage collected and I see some references to it being held by docking frames. I’m not sure what else I need to call in order to have the dockable totally unregistered and allow the component that once was there to be garbage collected (provided that I also don’t hold strong references to it).

What am I missing? Am I doing something wrong when adding or removing the dockable?

Thank you!
Eduardo

Oh I forgot, I’m also running the following line when removing a dockable:

dockControl.getContentArea().getCenter().removeDockable(dockable.intern());

Thanks!
Eduardo

Just call “dockable.setVisible(false)” before removing it from the CControl. You should not need to call the line with “getCenter().removeDockable”.
A few weeks ago there was an issue concerning MultipleCDockables not beeing garbage collected, so I’ll double check the reference problem. But in theory setVisisble + removeSingleDockable should be enough to remove a dockable completely.

According to my VisualVM it works well enough, but not instantaneously. Some Swing/AWT classes keep a reference to Components even after they were made invisible. After some time (e.g. after resizing the window or when the focus is transfered) they remove their reference and the Dockables are garbage collected.