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?

Was it helpful?

Solution

Rounded to a multiple of 16 bytes. Objects can be 16B, 32B, 48B, etc

Licensed under: CC-BY-SA with attribution
scroll top