Avatar of FrancineTaylor
FrancineTaylor
 asked on

Trying to find memory leak in process

I have a backend process that is called periodically by a service.  It checks a directory to see if there are any messages to handle.  QA tells me that if the service is running, even if it isn't processing any messages, it causes gradual memory usage increase.  An almost identical service (from which I copied my service) doesn't cause memory usage to increase.

I'm hoping to be able to see the memory usage increase when I run the service on my local machine, so I can comment out the various processes one at a time to figure out where the leakage is occurring, but I'm not sure how to do it.  There is a single entry method that the process uses, so I'm hoping if I take my snapshot and the beginning and end of the method, I should be able to tell if there was anything left open.

What could I use to gather this information in a way that would tell me if memory leakage was occuring inside a particular method?
C#

Avatar of undefined
Last Comment
algorith

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
sujithmd

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
iHadi

The CLR components and garbage collection differs according to the hardware and system resources (optimization stuff), so emulating the exact memory behavior happening on a server on your PC is not a simple task.

I suggest you use a .NET CLR memory profiling software by installing it on the production system.

You can also submit the code of that 'particular' method here so the experts can help you more and point out any code that is causing the memory leaks.
algorith

Is your service written in C#?  Microsoft states "Because of the garbage collection package that is implemented in the Microsoft .NET Framework, it is not possible to have a memory leak in managed code. "

(although it is possible in unmanaged code)

OTOH in C++ you can use the "debug heap" and the "Heap State Reporting Functions"
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes