Sizeof for Java
By sundararajan on Sep 04, 2004
sizeof operator is not available in Java. But, at times you may want to know size of your Java objects. Size of an object depends on VM implementation. Number of header words in an object ( "class pointer" etc.), pointer size (32/64 bit) and alignment variations make object size dependent on VM implementation. An article by Vladimir Roubtsov explains how to measure sizeof objects.
With J2SE 1.5, we can get size in 2 new ways (as I know), without using profilers or native agents.