What does Unreachable mean?

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
Posts: 2
Joined: Thu Dec 06, 2007 1:57 pm

What does Unreachable mean?

Post by cmurphy » Thu Dec 06, 2007 2:07 pm


I have recently fixed a pretty large memory leak.

I could see through the system tools that I was leaking about 1 meg every time I opened and closed a specific form.

So, I collected the snapshot information using .net memory profiler.

I needed to do a number of things to fix the problem (clearing arrays of images, removing handlers, setting static data back to null, etc..)

Now, I can clearly see that the memory leak is gone.

Going back to the data, I wanted to use the collection points to prove using both .net memory profiler AND the system tools that I fixed it.

I look at the old profiler sessions that I collected. I opened and closed the form 4 times (taking the first snapshot after the 1st).

The Types view shows that my form has 3 unreachable instances and 1 total, 1 new, and 1 removed instance (comparing the 4th to the 1st).

Based on what I've read, unreachable means that the object was a candidate for the garbage collector, but wasn't collected.

I was minimizing and maximizing the application in between each run, which causes the garbage collector to run.

I was also attaching to the process instead of running throught he profiler.

Can anybody help explain this to me. I don't see anything else in the Types tab that can prove that the memory leak existed to begin with.

I can see from the instance details tab that there were roots pointing to the form. Would that be the data that I would use to prove to people that I had the memory leak to begin with and don't anymore?

Posts: 2
Joined: Thu Dec 06, 2007 1:57 pm

More Info

Post by cmurphy » Thu Dec 06, 2007 2:10 pm

Also, I failed to note that when running my new code, there are 0 unreachable, 1 new and 1 removed instances.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Thu Dec 06, 2007 6:45 pm

An unreachable instance is an instance that exists on the managed heap, but which is not reachable from any root.

Unreachable instances can occur when you collect a snapshot on an attached process, or when heap utilization tracking is enabled and you collect a gen #0 snapshot. The reason for this is that the runtime has not performed a full garbage collection (GC) at the time of the snapshot. Since a full GC has not been performed, all instances have not been investigated and there might be unreachable instances on the heap.

This is a normal behavior for a generational garbage collector, and an unreachable instance does not indicate a memory leak (even though unreachable instances might indicate inefficient heap memory utilization). At the next full garbage collect, all unreachable instances will be collected.

From your description it does not seem like you have a memory leak when opening and closing the form. If you have one new and one removed instance, one Form instance has been replaced when opening and closing the form. It is possible that the last form instance should have been GCed as well, but at least it doesn't seem to be a memory leak that will grow over time. If this is the memory problem you have fixed, it's reasonable to believe that you investigated the root path to find out what caused the problem. But without more information it's hard to tell.

Note that minimizing the application will not cause the garbage collector to run, but Windows will trim the working set of the application.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests