Java memory areas in java 8

后端 未结 1 1607
滥情空心
滥情空心 2021-01-01 07:44

I have read a lot about java memory areas, but looks like it is just a mess. Mostly due to the introduction of a new MetaSpace area instead of PermGen

相关标签:
1条回答
  • 2021-01-01 08:20
    1. Does the structure of memory areas depend on the implementation of JVM ?

    Absolutely. PermGen or Metaspace are just implementation details of a particular JVM. The following answers are about HotSpot JVM, the reference implementation of Java SE virtual machine.

    1. What areas does the heap include in java8+ ?

    For the above reason it would be more correct to say "in JDK 8" rather than "in Java 8".

    The structure of Java Heap depends on the selected GC algorithm. E.g. with Parallel GC and CMS the heap is divided into Old and Young generations, where the latter consists of Eden and two Survivor Spaces.

    G1 Heap is divided into the regions of the same size. Epsilon GC heap is a single monolithic area. And so on.

    1. Where the static methods and variables are stored before java8 and java8+ ?

    Methods (both static and non-static) reside in Metaspace in JDK 8 or in PermGen prior to JDK 8. Not sure what you mean by "variables": field values are in Java Heap, the field metadata (names, types, offsets) is in Metaspace.

    1. Does the MetaSpace store anything except class meta-data info ?

    The following items are stored in Metaspace:

    • Classes (their internal representation)
    • Symbols (names and signatures)
    • Primitive arrays (e.g. field metadata is represented as an array of unsigned shorts)
    • Methods and their bytecodes
    • Method counters
    • Constant pools and CP caches
    • Annotations

    All of these can be considered "class metadata".

    0 讨论(0)
提交回复
热议问题