开发者

Is there any configuration for the garbage collector?

As I understand it, the garbage collector adjusts isself as the application runs, the threshhold used for example, when objects on the managed heaps are collected is adjusted (according to MSDN) over time.

If an appli开发者_高级运维cation crashes, does the runtime remember it's previous garbage collection 'settings' or any other settings?


Yes, there's a heuristic in the garbage collector algorithm that makes it automatically adjust the allocation strategy. The most visible side-effect of this is seeing the gen 0 heap size growing as the program is running and consuming memory. Typically starts at 2 MB, it can get to ~8 MB if the program consumes memory rapidly. The performance counters visible in Perfmon.exe are good for this.

The emphasis is very much on "automatic", this code was written with the flat-out assumption that programmers don't have enough information available to them to properly steer the algorithm. The only "hooks" are stuff that the GC cannot know about, like unmanaged memory usage (GC.AddMemoryPressure) or the role of the program (app.exe.config).

The details of the heuristic are not documented. However, you can glean some background info from today's publishing house for software algorithm documentation, the US Patent Office. Most of Microsoft's GC algorithms patents are credited to Patrick Dussud, you can easily find them back with a google query on his name. Here's a relevant one.


No, the runtime doesn't remember it's previous garbage collection 'settings' that its learned during the run.

What you can configure is concurrent garbage collection by putting the following in the config file:

<configuration>
   <runtime>
      <gcServer enabled="true"/>
   </runtime>
</configuration> 

Or:

<configuration>
   <runtime>
      <gcConcurrent enabled="false"/>
   </runtime>
</configuration>

Full documentation for gcServer can be found in MSDN.

Full documentation for gcConcurrent can be found in MSDN.


Please refer to my answer which includes descriptions of the different GC configurations/modes at:

Determining which garbage collector is running

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜