DiscountASP.NET

Reducing .NET Core Memory Usage

Over the months of troubleshooting .NET Core memory issues, one of our customers kindly pointed out to us there is a simple solution you can apply, and that is to change the server garbage collection mode from server to workstation.  To do that, just change the “System.GC.Server” element in the project.json file in Visual Studio 2015 from “true” to “false“:

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

And because the settings have moved to the ASPNETCore.csproj file for Visual Studio 2017, you need to change the “ServerGarbageCollecton” XML node from “true” to “false“:

<PropertyGroup> 
    <ServerGarbageCollection>false</ServerGarbageCollection>
</PropertyGroup>

This is because according to Mark Vincze:

the CPU count greatly affects the amount of memory .NET will use with Server GC

And since all of the DiscountASP.NET’s servers run on multiple processors, changing this value should reduce the amount of memory that your .NET Core application will use.  Many thanks to Mark Vincze and his tests to help the .NET Community out.

Exit mobile version