Is every object rounded to the same size in Java?
https://softwareengineering.stackexchange.com/questions/200902
-
29-09-2020 - |
Question
According to this answer every object in Java is of the same size? Is the answer talking about the object itself or the reference to the object?
Here's the statement:
every object size is rounded to 16 bytes in Hotspot, so an object with a single byte field will take up precisely the same space as a single object with a long or double field;
I am completely baffled by the claim in this statement. So many upvotes to this answer further befuddled me.
Can some one please explain what is meant by the above statement?
Solution
Rounded to a multiple of 16 bytes. Objects can be 16B, 32B, 48B, etc
Licensed under: CC-BY-SA with attribution
Not affiliated with softwareengineering.stackexchange