What are unreachable objects in the Memory Analysis tool

0 Likes

Problem:

RAM Footprint analysis shows Unreachable Objects using the most memory

Resolution:

Unidentified GC roots / unreachable objects refer to entities such as objects pinned in memory by unmanaged code or thread-local static variables. The most common type of unreachable object is an object that wraps an operating system resource, such as a file handle, window handle, or network connection.

Unreachable objects should/will be collected and memory freed for the next object allocation. So you should be able to ignore them and concentrate on the other allocations.

Notes: If you attempt to collect Memory Leaks or RAM Footprint data for an application started under the VisualStudio .NET debugger (F5), all garbage collection roots will appear as 'unidentified GC roots' in the session data. To enable memory Analysis to properly

identify most garbage collection roots in Memory Leaks or RAM Footprint sessions, start your application without debugging (CTRL F5).

The Garbage Collector is able to track the lifetime of a managed object that encapsulates an unmanaged resource, but it does not have specific knowledge about how to clean up the resource.

It looks like the Memory Analysis tool obtains it's information directly from the Garbage Collector, so it can only report what the Garbage Collector reports to it.

The references below may provide some insight on the question:

'should I worry about unreachable objects?'

[Sorry, old link]

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconautomaticmemorymanagement.asp

[Dead link?] http://www.csharphelp.com/archives2/archive297

Old KB# 11094
Comment List
Anonymous
Related Discussions
Recommended