Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do Size and Inclusive Size mean in the Performance and Diagnostics display?

I am using the Visual Studio Performance Tools in an attempt to discover why my program is running out of memory. After guessing what to do I have produced this display:-

enter image description here

It seems to suggest here that the size of the object includes the object only and the inclusive size includes all the objects that object references. But the objects concerned are defined like this:-

Public Structure Temperature
    Implements IMeasurements, IComparable(Of Temperature)

    Private Const KELVIN_TO_CENTIGRADE     As Double = 273.15
    Private temperature As Double

    Friend Sub New(ByVal passed_temperature As Double)
        temperature = passed_temperature
    End Sub

    ' some other methods, operator overloads and the IComparable
    ' implementation

End Structure

so the sizes clearly don't mean that unless there is a staggering amount of wasted space associated with these structures.

So, does anyone know what this is all about? Am I completely missing the point here?

like image 1000
Brian Hooper Avatar asked Sep 18 '15 13:09

Brian Hooper


2 Answers

According to my experiments Size and Inclusive size are what is written on Visual Studio tooltips:

Total size of the objects in memory

and

Total size of the objects plus total size of all child objects

But for me most important things to understand are:

  1. Total size is visible size of object + overhead. This means that the following class takes 24 bytes on x64.

    class X {} 
    
  2. Inclusive size does not process children of value types. This means if your class has child of value type then objects that are referenced from latter are not calculated.

like image 192
Boris Nikitin Avatar answered Oct 13 '22 11:10

Boris Nikitin


Size is the object with simple data types. Inclusive is the object plus sub objects size.

like image 4
Dan Gifford Avatar answered Oct 13 '22 10:10

Dan Gifford