?
Solved

C# Memory Leak Detection Tools

Posted on 2002-06-25
15
Medium Priority
?
3,228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

 
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
 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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