Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak! #6984

Closed
aropb opened this issue Jan 24, 2019 · 17 comments
Closed

Memory Leak! #6984

aropb opened this issue Jan 24, 2019 · 17 comments
Assignees
Milestone

Comments

@aropb
Copy link

aropb commented Jan 24, 2019

Hello all,

I found a memory leak in a simple project (.NET Core 2.2.1, OS Windows 10 Pro 1803, Build 17134.523).
Screenshots and project attached.

The problem is very serious, because the production project takes all the memory and falls.
The size of Heap Generation 2 is constantly growing!

gcserver=off kestrel
webservertest gcserver off kestrel

gcserver=on httpsys
webservertest gcserver on httpsys

gcserver=off httpsys
webservertest gcserver off httpsys

WebTest.zip

@sebastienros
Copy link
Member

he production project takes all the memory and falls

  • Can you explain what you mean by "falls"? Is the service actually recycled?
  • How much memory is available for the application on the server?

I am running your project locally to test the behavior on my side, thanks for providing it.

@sebastienros sebastienros self-assigned this Jan 24, 2019
@sebastienros
Copy link
Member

More questions:

  • How much load should I send to start seeing this behavior? Is running you sample "auto refresh" page enough?
  • Can you try to take a dump at some point, and another one later on, ideally when you think it's running out of memory?

@aropb
Copy link
Author

aropb commented Jan 24, 2019 via email

@muratg
Copy link
Contributor

muratg commented Jan 24, 2019

@aropb could you please answer @sebastienros's first two questions as well?

@aropb
Copy link
Author

aropb commented Jan 25, 2019

Hi,

The server becomes unavailable to clients. The Service must be restarted. On the server 6GB is available, the server is virtual.

Production server:

OS Name: Microsoft Windows Server 2012 R2 Standard
OS Version: 6.3.9600 N/A Build 9600
System Manufacturer: VMware, Inc.
Processor(s): 2 Processor(s) Installed.
[01]: Intel64 Family 6 Model 45 Stepping 2 GenuineIntel ~2397 Mhz
[02]: Intel64 Family 6 Model 45 Stepping 2 GenuineIntel ~2397 Mhz

Total Physical Memory: 8 191 MB
Available Physical Memory: 6 328 MB
Virtual Memory: Max Size: 9 983 MB
Virtual Memory: Available: 8 194 MB
Virtual Memory: In Use: 1 789 MB

prodserver1

If the memory is all over the log file like this:

2019-01-11 11:40:22.7350 Microsoft.AspNetCore.Server.HttpSys.LogHelper.LogException Error: ListenForNextRequestAsync An operation was attempted on a nonexistent network connection at Microsoft.AspNetCore.Server.HttpSys.MessagePump.ProcessRequestsWorker() ExecutionContext.RunInternal => d__22.MoveNext => LogHelper.LogException
2019-01-11 12:28:42.4670 Microsoft.AspNetCore.Server.HttpSys.LogHelper.LogException Error: ListenForNextRequestAsync An operation was attempted on a nonexistent network connection at Microsoft.AspNetCore.Server.HttpSys.MessagePump.ProcessRequestsWorker() ExecutionContext.RunInternal => d__22.MoveNext => LogHelper.LogException
2019-01-11 12:28:42.4670 Microsoft.AspNetCore.Server.HttpSys.LogHelper.LogException Error: ListenForNextRequestAsync An operation was attempted on a nonexistent network connection at Microsoft.AspNetCore.Server.HttpSys.MessagePump.ProcessRequestsWorker() ExecutionContext.RunInternal => d__22.MoveNext => LogHelper.LogException

Dump of WebServerTest from dotMemory:
WebServerTest netcore 2.2.1 gcServer off httpsys.dmw.zip

@aropb
Copy link
Author

aropb commented Jan 25, 2019

The application log on the PC (Windows 10 Pro, x64, 8Gb, i7):

jetbrains dotmemory 2019-01-25 08 52 54
jetbrains dotmemory 2019-01-25 08 53 32
jetbrains dotmemory 2019-01-25 08 54 13

SDK for .NET Core:
Version: 2.2.103
Commit: 8edbc2570a

Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62

@aropb
Copy link
Author

aropb commented Jan 28, 2019

@sebastienros, Do you need some more information? Thanks.

@sebastienros
Copy link
Member

No, sorry for the delay, I just need more time. Thanks.

@aropb
Copy link
Author

aropb commented Feb 4, 2019

Hi, @sebastienros, when can I expect an answer? Thanks.

@sebastienros
Copy link
Member

I can't repro an issue.

I have published the application you provided with the publish.cmd script, and ran it with a much higher load than what you suggested. I also defined logging at the Warning level otherwise every requests were logged on the console. On my machine the memory is very stable at 30MB which makes sense as you disabled server GC.

Does you issue only happen through IIS in-process?

@aropb
Copy link
Author

aropb commented Feb 7, 2019

No, IIS i don't use.

@aropb aropb closed this as completed Feb 7, 2019
@aropb aropb reopened this Feb 7, 2019
@aropb
Copy link
Author

aropb commented Feb 7, 2019

Please, write your PC and OS specification.

@sebastienros
Copy link
Member

Windows 10, .NET Core 2.2.1

@aropb
Copy link
Author

aropb commented Feb 8, 2019

@sebastienros, Hi.
I can not understand why my project memory is always growing. I can't find the cause, but maybe it's normal behavior?

profiling_ webaccmng windows service - net memory profiler 2019-02-08 12 45 21
profiling_ webaccmng windows service - net memory profiler 2019-02-08 12 47 28

Dump:
https://drive.google.com/open?id=1sfIJMmnHf5RQjsPr-P1nZ63iDMj7H1Ot

@sebastienros
Copy link
Member

It might just be that gen2 GC hasn't triggered yet. Using 60MB of memory is very low, the GC will only start once it hits memory pressure, meaning the OS tells the application that it's about to use too much memory. But I might be wrong. Let it run for hours, take a memory dump (one from the task manager is fine) at the middle of the run and right before your stop it once it's taking half your system memory. Taking two dumps will let us know what objects were created during this window.

Take a look at this comment where the process takes more than 2GB and the GC is never actually called, only because it doesn't have to as the available memory is still plenty. It might not be the "expected" scenario from an application developer's perspective though, and this will be changed in .NET 3.0.

@muratg muratg added this to the Discussions milestone Feb 8, 2019
@aropb
Copy link
Author

aropb commented Feb 9, 2019

@sebastienros Hi, I found my bug in the controller. I'm sorry.

I used in "Select/Where" from DatabaseContext a not static method of a controller.
It's bad that the netcore compiler misses such errors.

Thanks.

@aropb aropb closed this as completed Feb 9, 2019
@aropb
Copy link
Author

aropb commented Feb 9, 2019

dotnet/efcore#13048

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants