How large, in bytes, is a boxed primitive like java.lang.Integer
or java.lang.Character
in Java?
An int
is 4 bytes, a typical
It's more than that.
Every object reference has additional overhead, such as a Class reference. Not only that, your 4-byte pointer isn't quite accurate. It's a reference, so it's an ID plus a pointer, AND that pointer may be 8 bytes if you are on a 64 bit JVM.
There also appear to be VM implementation differences. Best way to be sure on this would be to pull it up in a profiler.
My (Super SWAG) estimate would be. Object reference 16 bytes (64 bit JVM) Class reference 16 bytes primitive value 4 bytes (Assuming int.) Total. 36 bytes.
EDIT: Now that your specify 32-bit JVM my SWAG would be 20 bytes using same math above.