Question: I have a list called `Population`, is a great list of very many positions and at some point I stop using it. How I can free the resources?
Then this is part of the code:

```
 private List <BasePopulation> Population=new List <BasePopulation>();
 Population.SomeMethod();
 Population.Clear();

```

I used the Clear method, but not works. Any idea?

Answer: 
The problem may be that `Clear` is not doing what you think it is. `Clear` simply marks the `List` as being empty without resizing the internal array that it uses behind the scenes. It will, however, remove all references to the individual `BasePopulation` instances. So if no other data structure has a reference to them they will be eligible for garbage collection. But, it will **not** reduce the size of the `List` directly. I just verified this using ILSpy.

You have two options.

1. Set `Population = null`. This will unroot the entire object instance making it eligible for garbage collection.
2. Call `TrimExcess` on this `List`. This will resize the internal array.
The best possible thing you could do is nothing. Garbage Collector GC does this job automatically for you. Since List is not `IDisposable` you cannot dispose it.

`Clear` would simply remove elements from the List but wouldn't dispose it.