Garbage Collection does not reduce current memory usage - in release mode. Why?

前端 未结 10 987
渐次进展
渐次进展 2020-12-06 14:18

I built a quick program that needed to loop through an enormous log file (a couple of million records) and find various bits and pieces from inside. Because the volume of da

10条回答
  •  失恋的感觉
    2020-12-06 15:16

    The garbage collector is not guaranteed to run when you call Collect(). It simply flags the object for collection. The next time the GC runs it will "collect" the flagged object.

    There is no way in .NET to force the GC to collect at a specific point in time - if you need this functionality you'll need to go to native code.

提交回复
热议问题