We have a memory leak issue due to controls being retained by UltraToolbarsManager.
Here is the architecture we have: Control1 has a UltraToolbarsManager. Control1 creates several Control2 objects in tabs. Control2 objects have also UltraGrids. We use the UltraToolbarsManager of Control1 to set the contextMenuUltra's of the UltraGrids of the Control2 objects.
As we close the Control2 objects via tabs, we realize that those Control2 objects are not disposed off the memory entirely, because they are retained by Control1.UltraToolbarsManager.contextMenuUltras.
In order to overcome this issue, we have tried Control1.UltraToolbarsManager.SetContextMenuUltra(UltraGridXYZ, null). However, we realized that even though UltraGridXYZ was disposed, the Control2 object was still retained in the memory, via UltraToolbarsManager.contextMenuUltras.val[]..._target.
Is there a way to detach the Control2 object from the UltraToolbarsManager at the end of its life cycle so that it doesn't remain in the memory? Or shall we maintain a separate UltraToolbarsManager for each Control2 object, that we create?
Hi Burak,
Mike B. asked be to take a look at your sample, and I think there's some confusion here.
You seem to be expecting the closing the Tab will Dispose the controls on that tab. That is not a correct expectation. The Tab control does not, and should not, dispose the controls. You created those controls and you are responsible for disposing them when they are no longer needed. It would be a bad idea for the Tab control to assume that just because the tab was closed that those controls aren't needed any more. You could just as easily want to keep those controls around and re-use them for a new tab or move them somewhere else and the tab control has no way of knowing that.
In fact, not only does the tab control not dispose the controls on the tab, the tab itself is not disposed or even removed from the control. Closing a tab just hides it, it's not removed from the Tabs collection.
If you want the controls to be disposed, then I recommend handling the TabClosed (or TabClosing) event of the UltraTabControl. You could remove the tab itself and also dispose of any controls that are no longer needed inside this event.