In .NET, is GC.MaxGeneration never 2?

As far as I understand, there are three generations of garbage collectors - 0, 1 and 2 for all versions of .NET.

Are there any circumstances under which a check GC.MaxGenerationwill lead to anything other than 2? Are there GCs for other frameworks that have a different number of GC generations?

+5
source share
1 answer

It should be noted that GC.MaxGeneration , which is constant for the lifetime of the application, is itself a detail of the implementation:

Developer Notes

For this implementation, the value of the returned MaxGenerationproperty is guaranteed to remain constant for the lifetime of the application.

, MaxGeneration 2 .NET, ( , getter).

. , Mono Boehm non-generational GC (MaxGeneration 0 ), SGen generational GC ( , MaxGeneration 1 ).

+8

All Articles