I have a densely populated arraylist that I want to clean and reuse. If I clear it, will it free this previously used memory?
I should also mention that arraylist is a private read-only field for the class, which still has a lot of active work after I first used arraylist. Therefore, I canβt wait for garbage collection after the class goes beyond.
Is the Clear method fast enough? Or should I destroy and create a new arraylist?
Question update:
If I have a field declared this way (thanks to John's advice)
then I populate it ... (strongly)
Now, if instead of cleaning and trimming, I can just call:
tasks = new List<Task>();
Would this be recommended?
Jl.
source share