Is Method area still present in Java 8?

Here is the runtime data storage for HotSpot VM In Java 8

Heap

  • Has got all your objects created using new, including String constant pool
  • Contains your fields/instance variables

MetaSpace(Method Area)

  • Contains static data(Class variables and static methods)
  • Data in here is accessible by Heap, JVM stack
  • Unlike <=Java7 PermGen which takes JVM process memory which is limited and can't be expanded at runtime. MetaSpace uses native memory

JVM Stack

  • Current execution of your program.
  • Contains local variables
  • It's a thread

Native Stack

  • Used for native method executions, as Java core language has some native stuff
  • It's also a thread

PC register/ Instruction Sets

  • Holds the JVM memory addresses(Not Native address) for each JVM instruction in your stack
  • Generally each entry in JVM/native stack refers to PC registers for addresses to get actual data from Heap/MetaSpace
  • Each stack is associated with a PC register

Since Method Area is a logical concept described in the specification, every JVM has a Method Area, though that doesn’t imply that it has to be reflected in the implementation code. Likewise, the Java Heap Space is specified as a concept in the specification, to be the storage of all Java objects, therefore all Java objects are stored in the Heap, per definition, regardless of how it is actually implemented.

Unlike the Perm Gen, which contained Java objects and JVM data structures other than Java objects, the memory layout of the HotSpot JVM for Java 8 has a clear separation. The Old Gen still only contains Java objects, whereas the Metaspace only contains JVM specific data and no Java objects. So Java objects formerly stored in the Perm Gen have been moved to the Old Gen. Since the Method Area contains artifacts “such as the run-time constant pool, field and method data, and the code for methods and constructors…”, in other words non-Java-objects (the pool may contain references to heap objects though), it is part of the Metaspace now.

You could now discuss whether the Metaspace is an implementation of Method Area or may contain more than the Method Area, but this has no practical relevance. Practically, the JVM contains code to manage the Metaspace and its contained artifacts and does not need to care whether these artifacts do logically belong to what the specification describes as “Method Area” or not.