This question already has an answer here:
-
reference type size in java
5 answers
What is the size of reference variables in java? I am quite sure it wont be dependent upon the architecture or is it? Does it bear any resemblance with concept of pointers in C? I have tries but could not get any convincing answer.
The amount of memory used by a reference depends on several parameters:
- on a 32-bit JVM, it will be 32 bits
- on a 64-bit JVM, it can be 32 or 64 bits depending on configuration. On hotspot for example, compressed ordinary object pointers is activated by default and the size of a reference is 32 bits. If you deactivate the option with
-XX:-UseCompressedOops
, they will use 64 bits.