dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.51k stars 10.04k forks source link

ASP.Net Core 2.1 not releasing memory #3494

Closed danmoseley closed 6 years ago

danmoseley commented 6 years ago

From @BinaryPatrick on September 4, 2018 18:4

An application running under a 15-25 requests per second load exhibits an endlessly growing memory footprint.

At first I thought I must have a memory leak, but when I run dotnet new webapi, compile the code using the release flag, and run it using dotnet webapi.dll, I get the same result.

I generated a load of ~20 GET requests a second to https://localhost:5001/api/values and after 10 minutes, the memory usage is up to 800Mb and growing.

This is with the stock asp.net webapi template. Is this the expected memory usage?

Copied from original issue: dotnet/corefx#32100

danmoseley commented 6 years ago

@BinaryPatrick hello, I don't know, let's move this to the ASP.NET repo. If you want to investigate yourself, you'll want to look at https://github.com/Microsoft/perfview

davidfowl commented 6 years ago

cc @sebastienros

binarypatrick commented 6 years ago

Also, I have tested this with <ServerGarbageCollection>false</ServerGarbageCollection> and it does not affect the memory consumption. Even after I stop the requests, the memory usage remains until I kill the webhost.

sebastienros commented 6 years ago

@BinaryPatrick We do it all day long, with much more complex applications, and we don't see this behavior. I even made a web app and article to show how everything works fine https://github.com/sebastienros/memoryleak

Can you check Console logging is disabled, or set the appsettings.json to Error only? It's missing in the current empty templates.

binarypatrick commented 6 years ago

Upgrading to ASP.Net Core 2.1.3 seems to have resolved the issue.

Eilon commented 6 years ago

Closing for now. If new info comes up, please let us know.

PrefabPanda commented 5 years ago

I get this particular problem too. Happens when using containers - in dotnet core 2.1 or 2.2.

2.0 doesn't seem to have the problem.

danmoseley commented 5 years ago

@prefabpanda I suggest opening a new issue with a link back,so this isn't overlooked. You might also try 3.0 preview 5.

kakins commented 5 years ago

I'm seeing this problem in aspnet core 2.2, not using containers. I look at the Diagnostic Tools in VS2019 and GC never gets called throughout the lifetime of the application. However, I do see GC being called in an ASP.NET 4.5 project.