vb.net 性能和诊断显示中的大小和包含大小是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32653213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What do Size and Inclusive Size mean in the Performance and Diagnostics display?
提问by Brian Hooper
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:-
我正在使用 Visual Studio 性能工具试图找出我的程序内存不足的原因。在猜测该怎么做后,我制作了此显示:-
It seems to suggest herethat 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?
那么,有人知道这是怎么回事吗?我在这里完全没有抓住重点吗?
回答by Boris Nikitin
According to my experiments Sizeand Inclusive sizeare what is written on Visual Studio tooltips:
根据我的实验,大小和包含大小是写在 Visual Studio 工具提示上的内容:
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:
但对我来说,最重要的理解是:
Total size is visible size of object + overhead. This means that the following class takes 24 bytes on x64.
class X {}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.
总大小是对象的可见大小 + 开销。这意味着以下类在 x64 上占用 24 个字节。
class X {}包含大小不处理值类型的子代。这意味着如果您的类具有值类型的子类,则不会计算从后者引用的对象。
回答by Dan Gifford
Size is the object with simple data types. Inclusive is the object plus sub objects size.
大小是具有简单数据类型的对象。包含是对象加上子对象的大小。


