jeno wrote:Of what? Primitives: actually amount of memory allocated is an implementation detail of the JVM, thus unspecified (it might as well allocate 8 byte for a 4-byte-int if that's somehow more efficient). The value range of primitives are specified in the JVM specs.
Is it possible to define & retrieve number of bytes allocated?
Nowhere have I found syntax to restrict the size like int(2)There is none.
or to retrieve bytes.Ever tried bitwise AND?
And from the forum replies, I see that the size may vary depending on the processor used. Is my understanding correct?Depends on your definition of "size".
I went through the details & like you had mentioned, can get only the size of objects & not for primitive data types.
Instrumentation package has something that can tell you the estimated object's size.
bitwise AND can be used only for long & integers, isn't it?
Ever tried bitwise AND?