在int数组是如何分配的内存 [英] How is memory allocated in int array

查看:400
本文介绍了在int数组是如何分配的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多少空间一个int数组占用?或int数组多少空间(以字节为单位)不会消耗,看起来是这样的:

How much space does a int array take up? Or how much space (in bytes) does a int array consumes that looks something like this:

 int[] SampleArray=new int[]{1,2,3,4};

时的内存分配特定语言?

Is memory allocation language specific ??

感谢大家。

推荐答案

既然你增添了不少的语言标记,我想要写C#。在C#中,这取决于操作系统。

Since you add a lot of language tags, I want to write for C#. In C#, this depends on operating system.

对于32位,每个 INT 是4字节和4字节也为参考对象,这使得4 * 4 + 4 = 20个字节

For 32-bit, each int is 4 byte and 4 byte also for reference to the object, that makes 4 * 4 + 4 = 20 byte

对于64位,每个 INT 是4字节和8字节也为参考对象,这使得4 * 4 + 8 = 24字节

For 64-bit, each int is 4 byte and 8 byte also for reference to the object, that makes 4 * 4 + 8 = 24 byte

C#5.0中果壳 22页;

到一个对象的每个参考需要额外的四个或八个字节,
  根据.NET运行时是否在32位或64位运行
  平台。

Each reference to an object requires an extra four or eight bytes, depending on whether the .NET runtime is running on a 32- or 64-bit platform.

这篇关于在int数组是如何分配的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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