8

Is it possible to use Server Garbage Collection on Azure App Service?

I have set gcServer in the web.config (D:\home\site\wwwroot\web.config) as follows:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <gcServer enabled="true" />
  </runtime>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\MyApplication.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

But GCSettings.IsServerGC still returns false.

Dave New
  • 38,496
  • 59
  • 215
  • 394
  • 1
    If the app service is [only running with a "single core no hyper-threading CPU"](http://stackoverflow.com/questions/11488324/when-server-gc-is-ignored) then service GC cannot be enabled. – stuartd Apr 27 '17 at 13:27

1 Answers1

17

According to this, you could see the remark:

If server garbage collection is not enabled, workstation garbage collection is in effect (with or without concurrent collection). Server garbage collection is available only on multiprocessor computers.

By default, if your web app service plan is multiprocessor, like B2, S2, it will automatic enabled gcServer.

But if your web app service plan is B1,S1, it only has one core, it will enable workstation.

Here is test example:

I have a page which has below codes:

string result;

        if (GCSettings.IsServerGC == true)
            result = "server";
        else
            result = "workstation";

        Response.Write(result);

Then I publish the web application to different app service plan.(B1,B2)

The result is as below:

enter image description here

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65
  • Any update? If you feel my answer is useful /helpful.Please mark it as an answer so that other folks could benefit from it. – Brando Zhang May 03 '17 at 03:11
  • Apologies for the late reply - yes, this solved my issue. I didn't realise the service plan option made a difference. – Dave New Jun 01 '17 at 15:31