Solved

C# Memory Leak Detection Tools

Posted on 2002-06-25
15
3,176 Views
Last Modified: 2011-04-14
Hi,

I'm looking for good memory leak detection tools that can analyze c# programs - other than : Purify, Microsoft Application Profiler or .Net memory profiler.

Thanks,
Yishay.
0
Comment
Question by:yl
  • 6
  • 3
  • 2
  • +4
15 Comments
 
LVL 4

Expert Comment

by:kpkp
ID: 7107082
I shouldn't be possible to create memory leaks with managed code in a C# program, it uses a garbage collector for memory management - or am I missing something?
0
 
LVL 1

Author Comment

by:yl
ID: 7107775
Theoretically you are right. However, if a C# program leaves unneeded objects with a reference to them (an application error), than they will not be freed by the garbage collector.
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 7112927
>However, if a C# program leaves unneeded objects with a reference to them (an application error), than they will not be freed by the garbage collector.


until the application is terminated or the object gets out of scope..
0
 
LVL 1

Author Comment

by:yl
ID: 7113916
I'm talking on a situation where the application is working for a long time without terminating.
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7117439
If its a purely managed application then chances of memory leaks are very slim. There have been instances when InterOp layer can generate some leaks because of Interface pointers not being released by the framework. It has nothing to do with your application. There seems to be some leaks in framework itself. Other than that it does not matter for how long your application runs. GC will kick in when it feels that your system is running low on resources or when its scheduled to run by framework. It runs on non deterministic schedule. You don't have to worry about objects not getting collected. Trust GC.. they will get cleaned up if they are not in use anymore. One thing that you can do to reduce the load and chances of memory leaks are that make sure that you call Dispose on objects that hold refereces to Win32 kernel objects like File handles, GDI objects, etc.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7121502
Any update?
0
 
LVL 1

Author Comment

by:yl
ID: 7122263
I'm not worried about my unreferenced application objects not being collected.
I need the tool in order to find objects that the application forgot to dereference.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 22

Expert Comment

by:CJ_S
ID: 7122568
>> I need the tool in order to find objects that the
>> application forgot to dereference.

That can simply not happen. Eventually (when the GC feels like it or when it is needed) the GC will step in and free your memory.

other than that naveenkohli has a very good reason. Naveen, any reference to that memory leak within the .Net framework?

CJ



0
 
LVL 1

Author Comment

by:yl
ID: 7124027
>> That can simply not happen. Eventually
>> (when the GC feels like it or when it
>> is needed) the GC will step in and free
>> your memory.

I assume you are referring to weak references.

But what about regular refeences? The GC can never free a referenced object (even one that the application forgot to dereference.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7124031
Garbage Collector will know when objects are not being used anymore. It knows it roots and when it goes out of scope. Whenever you have a reference object and you don't use it anymore (and forgot to dereference yourself) the GC will know and remove it when it drops in.

CJ
0
 
LVL 1

Author Comment

by:yl
ID: 7125092
I am talking about objects that are not being used anymore and Belong to some root. They will not be collected by the GC because the application forgot to dereference them and they are still descendants of root objects.
This phenomenon can be common in very large applications (such as ours).

The tool I am looking for will allow to take snapshots of the application and visually present objects that were created between the two snapshots and were not dereferenced.
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7125119
yl,
the scenario that you are talking about it more of a programming/implementationproblem rather than framework GC problem. If there is areference to an object anywhere that means that it is in use. GC and JIT compiler is smart in the sense that it can detect any unreachable object. For example if you created a reference to an object and exited that method or function without releasing it, then it becomes orphan. GC can detect that. And in the next cycle it will be cleaned up. You don't have to worry about it. But if you have reference to an object it is still in use, then it will not be cleaned up.

If you are that worried about clean up then you can force GC to run and clean up. But this is a big no no. It will degrade the performance of your application. Just trust GC. If object is not in use and is unreachable by your application, then it wlill go away.

CJ_S,
There is no reference to that memory leak in Interop. But we have seen it happening a lot that COM objects are not being released some time. Which end up in memory leaks.

Naveen
0
 
LVL 1

Author Comment

by:yl
ID: 7127213
naveenkohl,

>> the scenario that you are talking about it more of
>> a programming/implementationproblem rather than
>> framework GC problem

You are right. I am looking for a tool that will allow to detect such problems (other than the following tools: Purify, Microsoft Application Profiler or .Net Memory Profiler).
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9385909
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/Refund

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0
 

Accepted Solution

by:
SerCouWisMOD earned 0 total points
ID: 9441761
Question was closed per the recommendation

SerCouWisMOD
Community Support Moderator
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to go to Web page 2 52
How can I use this extension method? 8 36
.Net application crashing 6 22
Showdialog 8 21
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now