SteelReed

Search

Search posts, questions…

JVMQuestion 1 / 12

Middle

What memory areas does the JVM have? Where do static variables live?

Short answer

Shared areas: the heap (objects, arrays, managed by GC, capped by -Xmx) and metaspace (class metadata, in native memory since Java 8). Per-thread areas: the JVM stack, the PC register, the native method stack. Static variables live in the heap since Java 7.

JVM processSharedPer threadHeap: objects, arrays,static fieldsMetaspace: class metadatanative memoryJVM stack, PC register,native method stack

3 points to say:

  1. Shared: heap, metaspace, code cache; per thread: stack, PC register, native method stack.
  2. Static fields live in the heap (attached to the Class object); class metadata lives in metaspace.
  3. PermGen was replaced by metaspace in Java 8.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.