首页 > 其他 > 详细

JVM基础:GC

时间:2020-05-12 00:56:16      阅读:147      评论:0      收藏:0      [点我收藏+]

部分信息参考自:马士兵的JVM调优实战

 技术分享图片

 

垃圾回收算法:

1、标记清除   

2、复制:缺点:浪费一半的空间

3、标记压缩(Mark Sweep)

 

对象的产生、分配和回收过程 

技术分享图片

TLAB: Thread Local Allocation Buffer:

背景:   对象分配在堆上,而堆是一个全局共享的区域,当多个线程同一时刻操作堆内存分配对象空间时,就需要进行同步,而同步带来的效果就是对象分配效率变差,但是对于存在竞争激烈的分配场合仍然会导致效率变差。
TLAB:提高对象在堆上的分配效率而采用的一种手段,就是给每个线程分配一小块私有的堆空间,即TLAB是一块线程私有的堆空间(实际上是Eden区中划出的)

分代:
技术分享图片

Minor GC: 新生代

Major GC: 老年代

Full GC:  新生+老年

 

垃圾回收器:JDK1.8开始支持G1

垃圾回收器发展路线,随着内存越来越大而演进:从分代演化到不分代;  Serial:几十M; Parallel:几个G; CMS: 几十个G

CMS: Concurrent Mark Sweep    第3列:简称PS&PO

技术分享图片

Serial:a stop-the-world, copying collector which uses a signle GC thread

技术分享图片

Parallel Scavenge:a stop-the-world, copying collector which uses multiple GC thread

技术分享图片

Parallel Old:a compacting collector that uses multiple GC threads

技术分享图片

 ParNew: a stop-the-world, copying collector which uses multiple GC threads;it differs from "Paralledl Scavenge" in that it has enhancements that makes it useable with CMS(和CMS配对使用); 

For example, ParNew does the synchronization needed so that it can run during the concurrent phases of CMS

技术分享图片

CMS: concurrent mark sweep 非常重要的一个算法,面试重灾区;  a mostly concurrent, low-pause collector(暂停时间短)

4 phases:  1.initial mark  2.concurrent mark  3.remark  4.concurent sweep

 技术分享图片

 https://www.bilibili.com/video/BV1AZ4y147fD?p=3

  

JVM基础:GC

原文:https://www.cnblogs.com/clarino/p/12873422.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!