Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# Memory Leak Detection Tools

Posted on 2002-06-25
15
Medium Priority
?
3,249 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:Michel Sakr
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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 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