什么是.NET对象的内存开销开销、对象、内存、NET

由网友(没有迩°世界都黯淡无光)分享简介:什么是.NET对象的内存开销?我说的是一个任意裸机对象....内部.NET运作或引用的开销:What is the memory overhead of an Object in .NET? I'm talking about an arbitrary bare-bones object.... the overh...

什么是.NET对象的内存开销?我说的是一个任意裸机对象....内部.NET运作或引用的开销:

What is the memory overhead of an Object in .NET? I'm talking about an arbitrary bare-bones object.... the overhead of the internal .NET workings or references:

var obj = new System.Object();

多少空间OBJ占据堆?

How much space does obj occupy in the heap?

推荐答案

我说起这在博客中的。它的具体实现的,但对于Microsoft .NET CLR v4的,在x86 CLR具有8个字节的每个对象的开销,和x64的CLR具有16字节的每个对象的开销。

I talk about this in a blog post "Of memory and strings". It's implementation-specific, but for the Microsoft .NET CLR v4, the x86 CLR has a per-object overhead of 8 bytes, and the x64 CLR has a per-object overhead of 16 bytes.

然而,也有最小的时间分别是12和24字节大小 - 这只是你得到第4个或8个字节的自由,当你开始储存有用的信息:)

However, there are minimum sizes of 12 and 24 bytes respectively - it's just that you get the first 4 or 8 bytes "free" when you start storing useful information :)

(见博客文章以了解更多信息。)

(See the blog post for more information.)

阅读全文

相关推荐

最新文章