-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Describe the bug
I'm observing an annoying behavior with a .NET Core 3.1 web application. The memory used by the IIS process gradually increases over time. Before posting, I did some investigations...
First, I did some measurements with the diagnostic tool of visual studio. Basically, when I do nothing on the application, it stays stable. However, I have a GraphQL route that fetch users from the database and when I call this one, the memory used by the process increases and never goes down. I looked for a memory leak in there but at the end of the day, it's simply a simple EFCore query. However, I took some memory snapshots to try and find the culprit and I noticed that while the memory used by the process increased from 476 Mo to more than 800 Mo, the heap size only increased from 38 Mo to 40 Mo
I also did some tests with dotMemory and the result are the same than the one in here: #1976.
I end up with more than 700 Mo of "Unmanaged memory", however, as you can see in the yellow and purple rectangle, the .NET memory usage increased from 42 Mo to 60 Mo while the total memory increased from 430 Mo to 840 Mo. The graphic also show that after the GC fired, the heap memory gets released but the total memory is not.
As you can imagine, this is pretty annoying as after 3 days, the IIS process of the machine is up to 3 Go and I have to recycle the app pool. Not something I like to do :-)
Further technical details
- ASP.NET Core 3.1
PS C:\WINDOWS\system32> dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.200-preview.20614.14
Commit: 863605c8c3
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.200-preview.20614.14\
Host (useful for support):
Version: 5.0.1
Commit: b02e13abab
.NET SDKs installed:
2.1.519 [C:\Program Files\dotnet\sdk]
2.2.207 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]
5.0.101 [C:\Program Files\dotnet\sdk]
5.0.200-preview.20614.14 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
- Visual Studio 2019