views:

50

answers:

2

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 application crashes, does the runtime remember it's previous garbage collection 'settings' or any other settings?

+2  A: 

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.

brickner
It is the `<gcConcurrent>` element actually. Server GC is a very different algorithm.
Hans Passant
I've updated my answer to include gcConcurrent.
brickner
+1  A: 

Yes, there's a heuristic in the garbage collector algorithm that makes it automatically adjust the collection strategy. The most visible side-effect of this is seeing the gen 0 heap growing as the program is running and consuming memory. 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 collector 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.

Hans Passant