java GC 回收机制
GC回收机制
The Heap is divided into young and old generations as follows :
堆分为年轻代和老年代,如下:
Young Generation : It is place where lived for short period and divided into two spaces:
● Eden Space : When object created using new keyword memory allocated on this space.
● Survivor Space : This is the pool which contains objects which have survived after java garbage collection from Eden space.
年轻代:这个是短期存放的地方,可以分为两个部分:
● Eden Space: 当用new关键字创建对象时,在这个空间分配内存。
● Survivor Space:这个池用来存放,从Eden Space垃圾回收后存活的对象。
Old Generation : This pool is basically contain tenured and virtual (reserved) space and will be holding those objects which survived after garbage collection from Young Generation.
● Tenured Space: This memory pool contains objects which survived after multiple garbage collection means object which survived after garbage collection from Survivor space.
老年代:这个池基本上包含永久空间和虚拟空间,用来存放从年轻代垃圾回收后存活的对象。
● 永久空间:这个内存池包含从年轻代和老年代垃圾回收后存活的对象。
Permanent Generation : This memory pool as name also says contain permanent class metadata and descriptors information so PermGen space always reserved for classes and those that is tied to the classes for example static members.
Java8 Update: PermGen is replaced with Metaspace which is very similar.
Main difference is that Metaspace re-sizes dynamically i.e., It can expand at runtime.
Java Metaspace space: unbounded (default)
永久代:这个内存池像它的名字所说的一样,是用来存放永久class 元数据和描述符信息的。所以永久代空间总是保留类和他相关的类。例如静态成员。
Code Cache (Virtual or reserved) : If you are using HotSpot Java VM this includes code cache area that containing memory which will be used for compilation and storage of native code.
代码缓存:如果你用的是热点 java 虚拟器,就会包含代码缓存区域,这个区域的内存会用来编译和保存本地代码。