Garbage Collection every 100 seconds

后端 未结 12 1377
深忆病人
深忆病人 2021-02-03 11:32

Did any one encountered a scenario where application under high memory allocation load performed second generation collection every 100 seconds ?

We using 64-bit server

12条回答
  •  北恋
    北恋 (楼主)
    2021-02-03 11:56

    Since you are running on a Server, I am assuming it is a multicore machine as well. If this is the case, then you get Server GC flavor by default, so you don't need to set anything in your config file.

    The fact that you are getting Gen2 collection every 100 second is a factor of your allocation pattern and object lifetime pattern. if your allocation pattern is consistent, you will get consistent GC's, you can verify this behavior by looking under .Net CLR Memory perf counters under perfmon

    You will need to track the following metrics

    1. Gen0 Collections

    2. Gen 1 Collections

    3. Gen 2 Collections

    4. Allocated Bytes per second
    5. Bytes in all heaps.

    you should see the last metric moving like a jigsaw, increasing, a Gen2 Collection kicks in, decrease again, and the cycle repeats itself.

    To avoid this, you will need to check

    • Can you can objects between request, in pools?, this will avoid GC all together.
    • If not, can you decrease the number of objects you allocate per request?

    Hope this helps. Thanks

提交回复
热议问题