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

前端 未结 10 975
渐次进展
渐次进展 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:02

    Calling GC.Collect() is only a request to collect garbage, it's not an order, so the CLR may choose to ignore the request if it sees fit.

    For example, if there's a lot of garbage that would cause a noticable delay whilst collecting, but there's still free memory to service subsequent allocations, then the GC may opt to ignore your request.

提交回复
热议问题