[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
cms和g1的主要区别
1.cms是内存分布式分代连续的,也就是新生代一块连续的区间,年老代一块连续的区间,而g1是把堆分成了2048个region,每个区域region可以作为新生代也可以作为年老代,并且新生代的大小(也即region的个数)是根据期望的暂停时间动态调整的.
2.cms中大对象是直接分配到年老代的,而且ygc是没法回收年老代中的大对象的,必须要通过cms
gc才能回收,而g1中大对象是直接分配到Humongous大对象区域的(不过该区域一般认为是年老代),这里g1比较好的一点是ygc的时候就可以回收掉没有引用的大对象了,而不用等到mixed
gc再回收
3.cms的主要步骤有:初始标识(stw),并发标识,重新标识(stw),并发清理(cms的清理阶段是和应用线程并发进行的,使用的是标记清除算法,会产生大量的内存碎片);
g1的mixed gc中的全局并发标识阶段的主要步骤有:初始标识(stw),并发标识,重新标识(stw),初始清理(stw),并发清理,
混合gc中的初始清理+并发清理作用只是回收完全没有引用的region,然后计算要回收的region中垃圾的占比,排好序后为后面混合gc的时候加入CSet回收集中做好准备,比如为后面的8次gc回收做好计划,如每次回收把哪些region加入到cset集合中,真正的回收操作是紧跟着的mixed
gc的evacuation阶段,在evacuation阶段中会分8次回收全局并发标识阶段标记的Region,使用的是标记整理的算法,不会产生内存碎片(但是是stw的).
4.g1比cms会使用更多的内存和cpu负载,所以更适合用于大堆的应用