.NET对象大小 [英] .NET Object size

查看:150
本文介绍了.NET对象大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是堆分配对象在.NET中,包括管理开销的大小?我假定对象是沿4字节边界分配的,或者是使用了不同的方法?

What is the size of a heap-allocated Object in .net, including management overhead? I'm assuming Objects are allocated along 4-byte boundaries, or is a different approach used?

推荐答案

4字节边界。可能8字节边界在x64。

4 byte boundaries on x86. Possibly 8 byte boundaries on x64.

有基于x86的8个字节的开销,一类基准和一个同步块。我也不会感到惊讶地发现,12个或16个字节在x64。

There's an 8 byte overhead on x86, for a type reference and a sync block. I wouldn't be surprised to find that's 12 or 16 bytes on x64.

由于某些原因,在x86刚 System.Object的似乎需要12个字节的一个实例,使12个字节的绝对最小容量 - 而是一个类的< $ C C> INT 的的需要12个字节。我不知道为什么是这样的情况。

For some reason, on x86 an instance of just System.Object appears to take 12 bytes, making 12 bytes the absolute minimum size possible - but a class with an int also takes 12 bytes. I've no idea why this is the case.

这篇关于.NET对象大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆