Memory Usage in Java
Florian Weimer
fweimer at redhat.com
Sat Aug 9 18:12:53 UTC 2025
* John Dallman:
> On any remotely modern processor architecture, ten byte-sized
> variables will only occupy ten bytes of space. The way they get
> fetched into the processor is somewhat complicated but ensures that
> several of them will normally be fetched in one read.
That's not true for local variables, though. I don't know if Hotspot
has a clear preference, but other compilers tend not to use byte-level
access for local variables. The reasons vary. Register pair or
multi-register stores and loads are usually not available at the byte
level, and the instruction encoding for byte accesses might be less
compact.
Thanks,
Florian
More information about the discuss
mailing list