C
C#2y ago
AbsolutG

❔ Memory leak in a .NET 7 Webapi application

I'm at my wit's end, trying g to find a memory leak in my application. I have tried to make sure that all disposable objects are in *using..." blocks, I have been cleaning everything I can, but I can't get rid of the leak. Any tips on what to look for to solve this? Thanks!
5 Replies
Cracker
Cracker2y ago
where do you host your application ? Is it possible to take memory dump to analyze which objects/services are in high consumption There are lots of things can cause memory leak even third party nuget packages. As far as I experienced it was almost only solution for me to analyze memory dump from server (othar than review new feature back and point the problem easily) (it would be better If we can capture the memory dump from server once we suspect the leak is happening) (side note: dont share dump files to others because it might contain connection strings etc)
phaseshift
phaseshift2y ago
First you will need to be sure that you have a leak. How do you know you have one?
AbsolutG
AbsolutGOP2y ago
The application is hosted in a Windows Server under IIS. I know that it has a memory leak because the first time I put in online I got an out-of-memory message. I then checked task manager and saw the memory usage at almost 100%. As soon as I put it offline it went back down to normal levels. I then made several changes and every time I put it back online I monitored the memory usage and saw it slowly going up and never going back down again until I put it offline. I did take a memory dump to analyze it. In fact, I tried following all the steps as instructed in the Microsoft Learn page at https://learn.microsoft.com/en-us/dotnet/core/diagnostics/debug-memory-leak. I followed every single step to the letter of what is said in that page, but I'm getting an error. The problem is that when I get to the point where I need to enter the command "gcroot -all ...", which, as I understand it, is basically what will actually tell me what I need to know, all I get is an error: gcroot -all 7ffe1b5e7290 Unrecognized command or argument '7ffe1b5e7290' Any ideas? Thanks!
Tinefol
Tinefol2y ago
As its windows env, you may try .Net Memory Profiler, could be more convenient: https://memprofiler.com/
In-depth .NET Memory Profiling - .NET Memory Profiler
.NET Memory Profiler. A powerful tool for finding memory leaks and optimizing the memory usage in programs written in C#, VB.NET or any other .NET Language.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server