Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Note that this specifically mentions HotSpot and does not necessarily apply to any other JVM implementation (not even to newer and/or older versions of HotSpot, or HotSpot on another platform). Numbers like these are always implementation specific. – Joachim Sauer Jun 8 '13 at 17:02
up vote 4 down vote accepted

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

share|improve this answer
Where is the term multiple mentioned? – Geek Jun 8 '13 at 16:26
@Geek, the multiple is implied. Carelessly worded, admittedly, but most people can read between the lines. – Karl Bielefeldt Jun 8 '13 at 16:32
"Every object size is rounded to X" means a multiple of X. X could be "integers" or "powers of 2" or whatever, and the syntax is the same. (What's implied is that it's rounded UP.) – DougM Jun 8 '13 at 17:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.