dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.67k stars 1.06k forks source link

ServerGarbageCollection is not honored in SDK project and TargetFramework net47 #1720

Open davkean opened 6 years ago

davkean commented 6 years ago

From @Tornhoof on October 17, 2017 7:58

The setting server garbage collection in the new SDK project format is not honored for TargetFramework net47, it works for netcoreapp 2.0

<ServerGarbageCollection>true</ServerGarbageCollection>

Steps to repreoduce

  1. Create Console project
  2. TargetFramework net47
  3. Change project format to new format
  4. Add setting from above to property group
  5. Put in the main method:
    var latencyMode = System.Runtime.GCSettings.LatencyMode;
    var isServerGC = System.Runtime.GCSettings.IsServerGC;
    Console.WriteLine($"Server: {isServerGC}, Mode: {latencyMode}");

    Expected result

  6. Output: Server: True, Mode: Interactive

    Actual result

  7. Output is: Server: False, Mode: Interactive

Note: if you multi target the project with <TargetFrameworks>net47;netcoreapp2.0</TargetFrameworks you can see that the setting is properly used in .net core 2.0

This bug is kinda annoying since it means my Web App for ASP.NET Core 2.0 on .NET 4.7 is running on workstation GC and not on server background gc as it's usually done.

All my attempts to set complus_gcServer=true didn't make any difference.

Repro: ServerGcRepro.zip

For reference:

.NET-Befehlszeilentools (2.0.2)

Product Information:
 Version:            2.0.2
 Commit SHA-1 hash:  a04b4bf512

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.2\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS version is VS 2017 15.4.0

Copied from original issue: dotnet/project-system#2896

davkean commented 6 years ago

From @Pilchie on October 17, 2017 17:49

Seems like we would need to transform this into an app.config for net4x?

clearwaterstream commented 6 years ago

I'm running ASP.NET Core 2.0.1 with .NET 4.7.1 and for now I just add App.config with these settings:

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

GCSettings.IsServerGC is now set to true.

Would be nice if I did not have to do this and this was auto configured (and respected) via ServerGarbageCollection in csproj file ...

TheAngryByrd commented 6 years ago

👍 Experiencing for net45+

oofpez commented 6 years ago

also experiencing for net461.

specifying in web.config did not help.

haf commented 6 years ago

I experienced this while upgrading a project; and it was caused by previous runtimeConfig.json files being present without the setting. Deleting the output artifacts in bin/Release/netcoreapp2.0 and rebuilding caused this issue to go away for me on SDK .Net Core 2.1.401 / macOS latest / targeting net471+netcoreapp2.0.

github-actions[bot] commented 1 week ago

Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.

baronfel commented 1 week ago

This isn't stale per se - it's a valid feature request - we just haven't gotten to it and likely won't prioritize it because it only impacts .NET Framework.