How free memory used by a large list in C#?

后端 未结 5 1100
不知归路
不知归路 2020-12-14 15:55

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 th

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 16:39

    Edit, rewording my answer about Disposing. Ok, I must have been imagining things when I typed Clean. I'm assuming that if clearing all of the items from your list is not free resources, then the resources you are trying to free up are unmanaged. Based upon that assumption you'll need BasePopulation to implement IDisposable so when that object gets picked up by the garbage collector, those resources can then be released.

    http://msdn.microsoft.com/en-us/library/system.idisposable.aspx

提交回复
热议问题