Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server Garbage Collection on Azure App Service

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.

like image 809
Dave New Avatar asked Apr 27 '17 13:04

Dave New


1 Answers

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

like image 89
Brando Zhang Avatar answered Oct 08 '22 14:10

Brando Zhang