Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to find size of an object / datatype in Java?

801516Oct 30 2008 — edited Nov 1 2008
I am originally a c++ programmer. And most of the time i had the requirement to find size of an object or data variable or array to check its bounds and effective implementation. And in c++, sizeOf() operator was handy.

Is there any method/operator in Java to find the size of an object? (It may not be necessary, but does Java have something of that kind)

I googled and all i found was certain custom made programs that calculate size based on arbitary values, to be frank i was not satisfied with them.Is there any reliable way by which i can findout how much physical memory is occupied by each object?

I also want to know - what is the normal size of a boolean data type in java?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 29 2008
Added on Oct 30 2008
24 comments
638 views