Figuring out memory leak

ZinZin Posts: 5
Hi,

I'm new to memory leak detection in C# and Ants Memory Profiler. I found a few objects that I believe should have been released after GC.Collect() is called but they still show up in Ants profiler as being alive.

Do I have a memory leak and how do I figure out which one(s) causes the leak for this situation:

If A holds references to X1,X2,...Xn;
X1 holds references to X1a, X1b, X1c...X1z
X2 holds references to X2a, X2b, X2c...X2z

A is reported still alive and nobody holds references to it.

In my case A is Hashtable+HashtableEnumerator

Thank you very much.

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello Zin,

    This is a difficult question to answer without knowing the application and what it's been doing. If you want, you can send the profiler results to us at support@red-gate.com and we can try to have a look and offer some suggestions for you.
  • It took me a while to collect the data and the result file is ~80Mb, it won't work via emailing
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello Zin,

    Give me until tomorrow and I will set up a private FTP account for you on our FTP server.
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello Zin,

    If you're still interested, I've set up an FTP directory for you. Your username and password have been sent via email.
  • I have the samilar question, is there a guide line to pinpoint the memory leak cause using the memory profiler result? thanks
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    I'm under the impression that this depends a lot on the nature of the application. You need to know what objects should be 'live' and which ones should be disposed. Without that information, you're left squarely in the dark.

    The starting point is normally to look at the 'all objects' tab and find the number of objects that have been allocated and compare that to the live count.
  • I'm under the impression that this depends a lot on the nature of the application. You need to know what objects should be 'live' and which ones should be disposed. Without that information, you're left squarely in the dark.

    The starting point is normally to look at the 'all objects' tab and find the number of objects that have been allocated and compare that to the live count.

    'live' means the object is referenced and cannot be collected, right? how if an object is already out of calling range, such as a private string?
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello Caroline,

    As far as I'm aware, a live object is an object which still has a pointer to it on the program's stack. I'm sure it's more complex than that, though.
This discussion has been closed.