New Microsoft Word Document
New Microsoft Word Document
Key Points
Minimum Size:
The size of an empty class object is not zero. On
most modern JVMs (e.g., HotSpot), the minimum
size is typically 16 bytes on a 64-bit JVM without
compressed oops, and can be as low as 8 bytes on
some 32-bit JVMs12.
Why Not Zero?
The memory footprint comes from the object
header and alignment/padding requirements, not
from user-defined fields125.
JVM and Platform Dependent:
The exact size can vary based on:
JVM implementation
32-bit vs 64-bit architecture
JVM options like -XX:+UseCompressedOops1
Implications:
Creating many instances of an empty class can still
consume significant memory due to this
overhead12.
Example
java
class EmptyClass {}
EmptyClass obj = new EmptyClass();
Even though EmptyClass has no fields, obj will typically
occupy 16 bytes (on a standard 64-bit JVM) due to the
object header and alignment12.
Summary Table
JVM Type Typical Empty Object Size
In short:
An empty class in Java always has a nonzero memory
footprint—usually 8 to 16 bytes—because of JVM object
metadata, not because of user-defined fields