Held Bytes in Type Instance Details screen

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.

Moderator: SciTech Software

Held Bytes in Type Instance Details screen

Postby Pascal » Fri Jan 08, 2016 10:04 pm

I thought that held bytes was the sum of live instance itself + children held bytes. I have an object taking 848 bytes but one child alone takes 4960 bytes so how the parent can be 848?

heldbytes.png (11.63 KiB) Viewed 4305 times

Posts: 7
Joined: Tue Dec 01, 2015 8:53 pm

Re: Held Bytes in Type Instance Details screen

Postby Andreas Suurkuusk » Mon Jan 11, 2016 3:15 pm

No, the held bytes of an instance is not the sum of the instance itself plus the held bytes of the children. In this case you have something that resembles this:
Shared user instance

You have a User instance with some related data. This data is only reachable from the user instance and thus the data is counted as "Held bytes" for the User instance. However, the User instance is shared by multiple other instances, e.g. by multiple AccessResultsCacheKeys. Since the User instance is shared by more than one instance, it will not be held by a single instance.
Not held by single

If all instances that are using the shared User instance are considered at the same time, then the User instance will be held by this set of instances.
Held by multiple

You can read about held instances at here and here.

I hope this helps.
Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
Posts: 983
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden

Return to Using .NET Memory Profiler

Who is online

Users browsing this forum: Bing [Bot] and 5 guests

SciTech Software logo

© Copyright 2001-2016. SciTech Software AB
All rights reserved.

SciTech Software AB
Kartvägen 21
SE-175 46 Järfälla

E-mail: mail@scitech.se

Telephone: +46-706868081