Is there a way to determine if Mono GC uses GC or SGen GC at runtime?

I want it to be possible at runtime to determine if the runtime environment is using Mono GC GC or SGen GC. I tried a google search to solve problems and spent some time looking through the Mono documentation, but couldn't find a solution. Is there a way to determine which GC implementation Mono uses at runtime?

+4
source share
2 answers

You can use the GC.MaxGeneration property, it will be 0 when using GC Boehm and> 0 with sgen.

+8
source

Besides executing an executable GC, you can also find out if the NewRefCount (NRC) extensions are included (or not) in the GC.

:

bool NSObject.IsNewRefcountEnabled ();

. Touch.Unit :

        Writer.WriteLine ("[GC:\t{0}{1}]", GC.MaxGeneration == 0 ? "Boehm": "sgen", 
            NSObject.IsNewRefcountEnabled () ? "+NewRefCount" : String.Empty);

GC.

0

All Articles