-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
Milestone
Description
Description
A dotnet 7 application consumes much more memory on linux than a dotnet 6 or dotnet 5 application.
After upgrading our application to dotnet 7 we noticed a huge increase in memory consumption in linux, services that used 100 MB were now using twice that amount.
The base issue can be easily reproduced
- create new console application
- make sure it does not exit instantly, e.g. by using a while loop like:
while (true)
{
Console.WriteLine("Hello, World!");
Thread.Sleep(TimeSpan.FromSeconds(1));
}- Verify that in your .csproj file you are targeting dotnet 7:
<TargetFramework>net7.0</TargetFramework>- Switch to a
Releaseconfiguration - Start it under linux, e.g. by select
WSLin the dropdown to launch it. - Verify the used memory, e.g. by running
ps auxin your wsl shell and taking a look at theRSScolumn:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 5335 2.5 0.4 273549912 103944 pts/6 Sl+ 17:17 0:00 /usr/bin/dotnet /mnt/c/projects/sources/DotNet7Test/DotNet7Test/bin/Release/net7.0/DotNet7Test.dll
- Realize in horror that the console process consumes 100+ MB
- Stop the debugging
- Target dotnet 6 by updating your csproj file to:
<TargetFramework>net6.0</TargetFramework>- Start it under linux, e.g. by select
WSLin the dropdown to launch it. - Verify the used memory, e.g. by running
ps auxin your wsl shell and taking a look at theRSScolumn:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 5383 1.0 0.0 2961956 25504 pts/6 Sl+ 17:21 0:00 /usr/bin/dotnet /mnt/c/projects/sources/DotNet7Test/DotNet7Test/bin/Release/net6.0/DotNet7Test.dll
- Wonder why the same process consumes only 25MB using dotnet 6.
Configuration
Dotnet 7 on Linux x64, see above
Regression?
Yes, this is a major performance regression in dotnet 7 compared to dotnet 5 or 6.
Other information
Notes:
The memory consumption on windows on dotnet 7 is reasonable - it's just a little higher, but not by crazy amounts.
The difference between dotnet 5 and dotnet 6 on linux is negliable.
Take care,
Martin
Reactions are currently unavailable