How can I enable Server GC in .NET Core?

Viewed 11060

I have a .NET Core app (MyApp.exe) developed in VS2017 running on the 1.0.4 version of the SDK. I have tried adding an App.config with the following entries:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <gcServer enabled="true"/>
  </runtime>
</configuration>

Which on build is renamed to: MyApp.config.

But this does not change the GC mode; Any ideas?

2 Answers

There are few ways and they vary depends on the dotnet version.

enter image description here

runtimeconfig.json file:

{
   "runtimeOptions": {
      "configProperties": {
         "System.GC.Server": true
      }
   }
}

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <ServerGarbageCollection>true</ServerGarbageCollection>
  </PropertyGroup>

</Project>

More details you can find here

Related