dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.04k stars 4.68k forks source link

Memory Leak in Complex Software with Net 7 #81425

Open jogibear9988 opened 1 year ago

jogibear9988 commented 1 year ago

Description

Hello,

we have a very complex Net7 Program, wich increases Memory usage per day about arround 1GB. When I use MemoryProfiler it shows that most of the Memory is unmanged. How can I analyse where the memory is used?

I've a dump of the process: https://owncloud.mlog-onlineportal.de/index.php/s/7PKkvhYJ3EWYTEl Password: mlog

Maybe someone could help?

Reproduction Steps

dont know

Expected behavior

do not use so much memory

Actual behavior

uses a huge amount of memory

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.

Issue Details
### Description Hello, we have a very complex Net7 Program, wich increases Memory usage per day about arround 1GB. When I use MemoryProfiler it shows that most of the Memory is unmanged. How can I analyse where the memory is used? I've a dump of the process: https://owncloud.mlog-onlineportal.de/index.php/s/7PKkvhYJ3EWYTEl Password: mlog Maybe someone could help? ### Reproduction Steps dont know ### Expected behavior do not use so much memory ### Actual behavior uses a huge amount of memory ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration _No response_ ### Other information _No response_
Author: jogibear9988
Assignees: -
Labels: `area-GC-coreclr`
Milestone: -
mangod9 commented 1 year ago

Hel @jogibear9988, could you please provide more information about your application? Does the memory continue to increase if the application is left running or does it plateau after hitting steady state and you need to figure out what is consuming the memory?

jogibear9988 commented 1 year ago

no, it increases until we get outofmemory exceptions and the process crashes. For me it's unclear how I can analyze the memory dumps. I only find instructions how to analyze managed memory.

Next problem is, when we create the FullDump, after that we need to restart the software, or it will not work any more. This is another problem I need to find, wich we have on all our installations not only on this one with the memory increase.

We have the problem that after a full dump, 30-60seconds later our internal kestrel webserver does not work any more (without throwing any exception), but this is another problem where I'm also doing some tests.

Maoni0 commented 1 year ago

have you tried the DebugDiag tool? it's supposed to do native memory analysis as well.

jogibear9988 commented 1 year ago

Tried it now, everything is okay acording to this tool. Creates this Report: 20230130PuGMCC_MultipleRules.zip

Maoni0 commented 1 year ago

the tool reports you have 9.5GB committed on the native NT heap. are you not concerned with that?

Heap Details

Heap 1 - 0xb8fd0000 | NT Heap

Heap Name  Default process heap
Heap Description  This heap is created by default and shared by all modules in the process
Reserved memory  9,52 GBytes
Committed memory  9,5 GBytes(99,77% of reserved)
Uncommitted memory  22,4 MBytes(0,23% of reserved)
Number of heap segments  615 segments
Number of uncommitted ranges  640 range(s)
Size of largest uncommitted range  4,77 MBytes
Calculated heap fragmentationUnavailable

jogibear9988 commented 1 year ago

sure I'm concerned. But that is the problem. who is commiting this memory on the native heap? that's the thing i try to find out. And that's the question how to do?

Maoni0 commented 1 year ago

https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/using-umdh-to-find-a-user-mode-memory-leak

jogibear9988 commented 1 year ago

I now try to use vmmap. Anyone used it with a dotnet app? Anyone know this error: https://social.technet.microsoft.com/forums/Windows/en-US/2fd057d5-a5fe-4045-b724-9aac9627287f/vmmap-no-longer-shows-managed-heap-on-windows-10-version-1903?forum=miscutils&prof=required

PavelFischerCoupa commented 1 month ago

Hello, we have same issue with .net8 and amazon linux 2 containers. Gain +0.5Gb per day in native memory Currently trying to check if it is a production code, but so far didn't found any code, which produces it.

PavelFischerCoupa commented 1 month ago

Native memory reported by k8s: image But application does nothing: image

PavelFischerCoupa commented 3 weeks ago

We have found our issue: it was in the external dependency.