logoNEURAL COOK
SearchAll PostsTagsNotesAuthor
logoNEURAL COOK

A posts created with Next.js and Tailwind.css

Explore

  • All posts
  • Notes
  • Snippets
  • Tags
  • RSS feed

Connect

instagramtwitterfacebookyoutubelinkedinmailgithub

© 2026 VIKI. All rights reserved.

Built with
Contents
Java/JVM architectureJava Collections : A Complete Guide for DSAJava Object Anatomy: What lives in Memory?The Java Dev Environment That Just WorksJava Utility MethodUnderstanding the Servlet Ecosystem: From Tomcat to Micronaut
DNSHTTPIP AddressThe Comprehensive DNS Master Guide: Architecture, Protocol, and GovernanceThe OSI Reference Model: A Comprehensive GuideThe TCP/IP Stack: The Architecture of the Internet
LogsExamplesResources
Miscellaneous/java

Java Object Anatomy: What lives in Memory?

1 min read
On this pageThe Object Header
The Object HeaderMemory Alignment (Padding)

# The Object Header

Every Java object has a header consisting of:

  • Mark Word (8 bytes on 64-bit): Stores the hashcode, GC age (for generational moving), and lock information (biased locking, etc.).
  • Klass Pointer (4-8 bytes): A pointer to the class metadata in the Metaspace.
  • Array Length (4 bytes): Only present if the object is an array.

# Memory Alignment (Padding)

The JVM aligns objects to 8-byte boundaries. If an object’s data is 21 bytes, the JVM adds 3 bytes of "padding" to make it 24.

!!! "info" This is why choosing primitive types over boxed types (e.g., int vs Integer) saves massive amounts of memory in high-throughput systems—it avoids the header and padding overhead.

←PreviousJava Collections : A Complete Guide for DSANext→The Java Dev Environment That Just Works

On this page

The Object HeaderMemory Alignment (Padding)