How to free up memory - best method
-
I have a program that uses 4 different user controls that are loaded in a panel depending on what the user wants to do. I add each UserControl to the Controls collection of the panel, but each time I fire the event that adds the UserControl to the panel the memory usage of my application increases although I clear the Controls collection. I have managed to stop this by implementing this method in each UserControl:
public void Dispose() { Dispose(true); GC.SupressFinalize(this); }
Is this the best method to handle this? -
I have a program that uses 4 different user controls that are loaded in a panel depending on what the user wants to do. I add each UserControl to the Controls collection of the panel, but each time I fire the event that adds the UserControl to the panel the memory usage of my application increases although I clear the Controls collection. I have managed to stop this by implementing this method in each UserControl:
public void Dispose() { Dispose(true); GC.SupressFinalize(this); }
Is this the best method to handle this?You can invoke the Dispose all you want, but the system will take out the garbage when it deems time to do so. I am sure there has to be some way to coax it along :)
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus