Is there any way I could tell the size of an object/primitive inside of the ram? I may be completely incorrect on how this works. Also, is there any way to tell how much ram is being used by your program?
Heh, accidentally whacked "Appreciate" instead of "Quote". You're welcome
Primitives are all of a specific size according to the Java Language Spec (eg. 4 bytes for an int or float, 8 for longs and doubles, etc). Hotspot has documented somewhere what the overhead is for objects and arrays (which for example in the 32-bit JVM, is 8 bytes overhead for an ordinary Object and 12 bytes for an array). It's possibly the same for 64-bit with compressed OOPs, and possibly twice as big without.