For a typical 64 bit machine
Primitive Types
Object
Object size = total size of instance variable + Object overhead (16 bytes) + Padding
Padding = Memory usage padded to multiple of 8 Bytes ( Padding speeds up memory access & garbage collection)
ex: 16 Bytes + 4 Bytes + 4 Bytes (for multiple of 8 Bytes)
References: A reference to an object typically is a memory address and thus uses 8 bytes of memory
Inner Class: A nested non-static (inner) class such as our Node class requires an extra 8 bytes of overhead (for a reference to the enclosing instance).
Arrays: An array of primitive-type values typically requires 24 bytes of header information plus the memory needed to store the values
0 comments:
Post a Comment