Currently, I have a setup with an object hierarchy similar to below:
Now, there are only about 6 child objects, but several of those child objects can contain 60-100 granchild objects, of which, there are some that are arrays (one is 1000 in length).
Originally, I had a main UI form, which I would create multiple instances of, and it, essentially, played the role of the Parent object, with the child objects as properties. The application is MDI in nature, and when I unload the project, I unload all open forms and set them to Nothing, and in this main UI form's unload event, I set each child object to Nothing. I understand there would be some delay in releasing this memory...not a problem.
However, I wanted to move away from the current implementation to make it more general, and create a new class to act as the Parent object. So I have a public variable declared as this parent object, and when the program ends, I set it to nothing. I have tried arrays, the collection object, and the dictionary object. All are ridiculously slow in loading and unloading these objects.
1) Why is this so?
2) What is different from destroying them from the form's unload event and otherwise?
3) What workaround is available?
Essentially what I need is a super fast collection type class to act as my Parent, and the ability to create and destroy objects quickly. Hopefully someone has attacked this issue before and has a solution readily available.