Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

java - Memory requirements of an Object reference on a 64 bit JVM

A reference to an Object on a 32 bit JVM (at least on Hotspot) takes up 4 bytes.

Does the 64 bit Hotspot JVM need 8 bytes? Or is some clever compression going on? If not, every Object[] would require twice as much heap memory, which I somehow think (hope, expect) is not the case.

Update/extra question: Does this really matter, or is this a negligible increase, because most references point to objects that are much larger than a few bytes (whereas one might argue that those objects are in turn mostly comprised of references to other objects)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In a 64-bit system, object references are typically 8-byte long. But in recent JVMs from Sun/Oracle you can enable Compressed Oops, which reduce reference size to 4 bytes at the cost of a smaller limit on heap size.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...