内存分配:Java中引用占用了多少空间? [英] Memory allocation : How much space does a reference occupy in Java?

查看:424
本文介绍了内存分配:Java中引用占用了多少空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中我们编写了一个代码:

In Java we have written a code:

A a1;
a1 = new A();

编译器编译代码时保留多少字节的内存:

How many bytes of memory is reserved when compiler compiles the code:

A a1;


推荐答案

这是Java标准没有规定的,因此你应该不用担心。

That's not specified by the Java standard and thus you should not worry about it.

从技术上讲,引用通常与机器的字大小一样大,即32位机器上的32位和64位机器上的64位,尽管有些64位JVM使用特殊魔法允许32位引用。

Technically, references are usually as big as the machine's word size, i.e. 32 bit on a 32 bit machine and 64 bit on a 64 bit machine, though some 64 bit JVMs use special magic to allow 32 bit references.

这篇关于内存分配:Java中引用占用了多少空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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