Three Mode Of DotNet Garbage Collection

There are three mode of DotNet Garbage Collection working:Workstation GC with Concurrent GC off; Workstation GC with Concurrent GC on and Server GC.On the DotNet 2.0 and later you can change it by modifying the Config file or Configuration tools,for example,using following code to enable Server GC mode:
 

1.Workstation GC without Concurrent: for single-CPU server, the policy-engine will adjust the working frequency of GC and useing process of Hang -> Mark and Sweep  -> Compression -> Recovery to collecting the object.
2.Workstation GC with Concurrent: Concurrent GC is better than Non Concurrent GC mode in the reaction, it is the
default setting of winform applications and windows services.On single-CPU computer can only use the workstation GC mode,and default setting is the Workstation GC with Concurrent.
In this mode, CLR will temporarily suspend the application when generation 0 and 1 collected, parallel processing
only when generation 2 be collected,to using multi-CPU deal with Full GC phase :CLR cut Full GC phase into several

short sub-process on the thread and then thread be frozen and Full GC starting.In the time of thread be frozen outside,application is running normal.
This way usually set a large space to generation 0, so that CLR still carried out memory in generation 0 when the
Full GC phase, if generation 0 space exhausted also,the application will be suspended to waiting for Full GC completed.
3.Server GC:To be used on multi-CPU computer,this mode has a high performance and efficiency.CLR will create a
special GC thread for each CPU,but those gc threads can NOT working in the same time,it is NON-concurrent!So the

generation of 0,1,2 gc working will suspend the application.
There is a mode named 'background collection' In DotNet 4.0,This mode based on concurrent GC,as section 2:Full GC
phase in Workstation GC with Concurrent mode, CLR still carried out in generation 0 memory allocation, if space of

generation 0 is exhausted , then the application will be suspended and waiting for Full GC completed.
The 'background collection' deal with above processing like following:during the Full GC phase collect the
generation of 0,1 at the same time.The 'background collection' use a special thread to complete,the priority of this thread is  lower than task of collect generation 0,1 and will suspend application too.
The 'background collection' will adjust capacity of generation 0 and 1 to reduce times of collect.

 

Aicken(李鸣)


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值