Fix for issue #13153 - change SetGCConcurrent to TemporaryDisableConcurrentGC for...
authorDavid Mason <davmason@microsoft.com>
Wed, 14 Feb 2018 10:18:39 +0000 (02:18 -0800)
committerGitHub <noreply@github.com>
Wed, 14 Feb 2018 10:18:39 +0000 (02:18 -0800)
src/vm/profilinghelper.cpp

index b1fb228..d711100 100644 (file)
@@ -1193,9 +1193,15 @@ HRESULT ProfilingAPIUtility::LoadProfiler(
         // and kill objects without relocating and thus not doing a heap walk.
         if (CORProfilerTrackGC())
         {
-            LOG((LF_CORPROF, LL_INFO10, "**PROF: Turning off concurrent GC at startup.\n"));       
-            g_pConfig->SetGCconcurrent(0);
-            LOG((LF_CORPROF, LL_INFO10, "**PROF: Concurrent GC has been turned off at startup.\n"));       
+            LOG((LF_CORPROF, LL_INFO10, "**PROF: Turning off concurrent GC at startup.\n"));
+            // Previously we would use SetGCConcurrent(0) to indicate to the GC that it shouldn't even
+            // attempt to use concurrent GC. The standalone GC feature create a cycle during startup,
+            // where the profiler couldn't set startup flags for the GC. To overcome this, we call
+            // TempraryDisableConcurrentGC and never enable it again. This has a perf cost, since the
+            // GC will create concurrent GC data structures, but it is acceptable in the context of
+            // this kind of profiling.
+            GCHeapUtilities::GetGCHeap()->TemporaryDisableConcurrentGC();
+            LOG((LF_CORPROF, LL_INFO10, "**PROF: Concurrent GC has been turned off at startup.\n"));
         }
     }