(GC.TryStartNoGCRegion()) The method or operation is not implemented. on Mono

230 Views Asked by At

I'm trying to stop C# from collecting garbage for some time. I found that I can do this using the GC.TryStartNoGCRegion() method. However, this throws this exception:

Unhandled Exception: System.NotImplementedException: The method or operation is not implemented. at System.GC.StartNoGCRegionWorker (System.Int64 totalSize, System.Boolean hasLohSize, System.Int64 lohSize, System.Boolean disallowFullBlockingGC) [0x00000] in <1400ea11d6fd49d4939be686a9549fb4>:0 at System.GC.TryStartNoGCRegion (System.Int64 totalSize, System.Boolean disallowFullBlockingGC) [0x00000] in <1400ea11d6fd49d4939be686a9549fb4>:0 ...

I executed this line of code:

GC.TryStartNoGCRegion(4096, true)
1

There are 1 best solutions below

0
MomoVR On

Apparently it is Mono itself causing the error. In the source code GC.TryStartNoGCRegion() throws a System.NotImplementedException.