Method Area(Non-Heap Area)

Method Area(Non Heap Area) has two major parts:-

Method Area(Non-Heap Area)

1. Permanent Generation – This area stores class related data from class definitions, structures, methods, field, method (data and code) and constants. Can be regulated using -XX:PermSize and -XX:MaxPermSize. It can cause java.lang.OutOfMemoryError when it runs out if space.

This area stores per-class information such as:

  • Classloader Reference
  • Run Time Constant Pool
    • Numeric constants
    • Field references
    • Method References
    • Attributes
  • Field data
    • Per field
      • Name
      • Type
      • Modifiers
      • Attributes
  • Method data
    • Per method
      • Name
      • Return Type
      • Parameter Types (in order)
      • Modifiers
      • Attributes
  • Method code
    • Per method
      • Bytecodes
      • Operand stack size
      • Local variable size
      • Local variable table
      • Exception table

2. Code Cache – The JIT(Just in Time) compiler compiles the bytecode to native code. This native code is stored in the code cache area.

When the Code Cache gets filled up, the JVM will turn off JIT code compilation which can result in poor performance.

We can increase the code cache size using –XX:ReservedCodeCacheSize.

Also, we can configure -XX:+UseCodeCacheFlushing which is basically adding a Garbage Collection for the code cache.

Related Topics

Java Virtual Machine(JVM)

JVM Interview Questions


Leave a Reply

Your email address will not be published. Required fields are marked *