Garbage Collection every 100 seconds

后端 未结 12 1379
深忆病人
深忆病人 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:47

    For that to happen the memory use should be very consistent for both the process and the system as well. Garbage collection is triggered by either of these events:

    • Generation 0's budget is full
    • GC.Collect() is called
    • CLR wants to free memory
    • AppDomain shutdown
    • CLR shutdown

    The likely candidates in your case are probably regular collection (i.e. due to allocation) or a timed Collect().

    EDIT: Just to clarify about allocations. Allocation of regular objects always happen in generation 0 (exception is large objects of 85000 bytes or more, which are allocated on the large object heap). Instances are only moved to generation 1 and 2, when they survive a collection. There are no direct allocations in generation 1 and 2.

    Also, generation 2 collection (also known as a full collect) is performed when generation 0 / 1 collections do not free sufficient memory (or when a full collect is explicitly requested).

提交回复
热议问题