VMs differ in how they store variables, etc internally. Most modern 32-bit VMs are similar though. You can probably estimate the shallow size of a class instance like this:
sizeInBytes = C + 4 * (fieldCount)
Where C is some constant.
This is because typically all fields are given a word width, which is often still 4 bytes internally to the JVM. The deep size of the class is more difficult to compute, but basically you recursively add the size of each referent object. Arrays are typically 1*arr.length
bytes in size for booleans and bytes, 2*arr.length
for chars and shorts, 4*arr.length
for ints and floats, and 8*arr.length
for doubles and longs.
Probably the easiest way to get an estimate at runtime is to measure how Runtime.freeMemory()
changes as you instantiate objects of your class. None of this should be used for program logic of course; just for JVM tweaking or curiousity.