I am building contextual tab groups at runtime along with MDI forms. When I am ready to display a new form, I build my tab group and call the RefreshMerge method on my main form. Everything displays properly and works great. However, when I close my child MDI form, I am noticing a memory leak and the child form never disposes completely.
I have tried writing code that disposes each individual tool I add along with any popup galleries, ribbon groups, etc. However, the child form still never disposes completely The ANTS memory profiler tool show objects in the MergedTools Collection. Since I called the RefreshMerge on the main form's toolbarsmanager, I am wondering if there is anything else I need to dispose of. There appears to be a MergedTools collection somewhere. Is there a different method I should be calling to "unmerge" the child MDI form from the main form?
Hi Richard,
It sounds like you are using the ToolbarsManager correctly. The behavior you describe is unusual, as the tools from the closed form should be released when the form is closed. If it is possible for you to provide a sample application that reproduces the leak, we can look into it over here and try to determine what's causing it. If you would prefer not to upload to the public forum, let me know and I will open a support case to receive the sample.
Please let me know how you choose to proceed.
My project is too big and complex to boil down into a sample app to send to you. Can you give me the "best practice" steps for adding and then cleaning up contextual tabs? I'm currently walking through all the ribbon tabs, groups and collections and manually disposing of each item I added, but this is tedious and I might be missing something. Is there a better way to do this?