Size of Children and Circular References

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
stevenmcohn
Posts: 1
Joined: Mon May 11, 2009 12:57 pm

Size of Children and Circular References

Post by stevenmcohn » Mon May 11, 2009 1:04 pm

Hi, Suppose I have a hierarchical tree structure where each node is an object of one class. Each node may reference multiple data items where each data item is an object of another class.

First, is it true that if I examine one of these nodes that the "Size with Children" will report the size of the node instance plus the size of all data items referenced by that node? (And possibly anything reference by each data item, and so on.)

Second, now suppose that each child has a reference to its parent node. Without further analysis, this create a circular reference from parent to child to parent. It appears that the "Size with Children" will always be reported as UInt32.MaxValue. Am I reading this correctly? If so, are there any plans for MemProfiler to understand or at least flag these types of circular references?

Thanks,
\Steven

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

Post by Andreas Suurkuusk » Tue May 12, 2009 3:32 am

The "Size (with children)" value reflects the size of the instance, plus the size of all other instances that are reachable from it. Each instance is considered only once, i.e. the profiler will detect a circular reference and not include a previously included instance in the calculation.

Are you actually seeing "Size (with children)" presented as 4,294,967,295 (UInt32.MaxValue)? That should not be possible, so if that's the case, can you please provide more information about this?

In .NET Memory Profiler 3.5, the "Size (with children)" value has been replaced with "Reachable bytes" and "Held bytes". "Reachable bytes" is the same value as the "Size (with children)" value, but the "Held bytes" value only includes instances that are uniquely reachable through the selected instance. The held bytes value is probably a better metric for the memory usage of an instance.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests