I have a heavily populated arraylist, which I want to clear and reuse. If I clear it will it free up that previously used memory?
I should also mention that the arraylist is a private read only field of a class that still has lots of active work to do after I use the arraylist first time round. So I can't wait for garbage collection after class goes out of scope.
Is the Clear method fast enough? Or should I destroy and create a new arraylist?
Question update:
If I have field declared like this (thanks to Jon's advice)
/// <summary>
/// Collection of tasks.
/// </summary>
private List<Task> tasks = new List<Task>();
then I populate it.... (heavily)
Now if instead of clearing it and trimming, can I just call:
tasks = new List<Task>();
Would this be recommended?