Java memory areas in java 8

梦想的初衷 提交于 2019-11-29 12:02:25
  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".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!