I’m having some memory issues on an application I’m setting up that makes frequent use of “removeall” on a list of custom objects. Should something be done to each of the objects to be removed before running this function to clean up any mess?
Thanks!
RemoveAll will remove them from your collection. If there are any other references to the objects then they will continue to exist.
You could also be using some unmanaged resources that need to be cleaned up. Generally you would put these in a Dispose method if you’re implementing IDisposable and also in a Finalize method to ensure that they are cleaned up.
Otherwise, the garbage collector will clean up any managed resources. The only problems this can cause (and this is VERY rare) is that the garbage collector runs at a lower priority and if your processor is seriously pegged, it might not get enough cycles to clean up memory.