As far as bytecode is concerned, a reference behaves much the same as an int
or float
. long
and double
take up two stack slots. So it's as if references are four bytes. However, 64-bit systems often munge this so that they can use 64-bit pointers.
Some JVMs (I believe BEA JRockit for some time and recently added to Sun's) use "compressed oops" which is 32-bits which gets shifted left a few places to enable access tens of GB of memory on 64-bit systems. As well as reducing memory consumption, reducing the reference size also reduces the CPU-memory bandwidth and cache requirements, improving performance despite the extra fiddling.
I believe Azul's version of Hotspot uses 64-bit references, with 48-bits for address and 16-bit type information.