Heap Space

Java's Heap Space implementation.

Used to allocate memory to objects at run time

How is object stored in memory?

  • The actual data/structure that is stored on the heap starts with what's commonly called object header.
  • Header contains — a (compressed) class pointer
  • Class pointer —> an internal data structure
  • Internal data structure — defines layout of the class
  • Layout of class — stored in a separate memory area called Metaspace (or Compressed Class space if Compressed OOPs are used).
  • The pointer can be 4 or 8 bytes, depending on the architecture - even on 64-bit systems, it's usually 4 bytes due to the Compressed OOPs optimization.

References


Children
  1. Program Counter Register

Backlinks