JVM常用概念之垃圾回收设计与停顿

news2025/3/4 3:46:12

在我们应用程序运行期间,我们是需要尽可能避免垃圾回收。
请添加图片描述
图1:不同垃圾回收器的设计(黄色代表STW,绿色代表并发)

实验

计算机配置

Hardware Overview:

  Model Name:	MacBook Pro
  Model Identifier:	MacBookPro14,2
  Processor Name:	Intel Core i5
  Processor Speed:	3.1 GHz
  Number of Processors:	1
  Total Number of Cores:	2
  L2 Cache (per Core):	256 KB
  L3 Cache:	4 MB
  Memory:	8 GB
  Boot ROM Version:	428.0.0.0.0
  SMC Version (system):	2.44f1
  Serial Number (system):	
  Hardware UUID:	

JDK环境

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

实验源码

import java.util.*;

public class Case3 {
    static List<Object> array;
    public static void main(String [] args) {
        array = new ArrayList<>();
        for (int i = 0; i < 100000000; i++) {
            array.add(new Object());
        }
    }
}

用例

JDK9-G1

time java -Xms4G -Xmx4G -Xlog:gc Case3
[0.036s][info][gc] Using G1
[1.576s][info][gc] GC(0) Pause Young (G1 Evacuation Pause) 370M->366M(4096M) 952.195ms
[2.817s][info][gc] GC(1) Pause Young (G1 Evacuation Pause) 744M->747M(4096M) 847.381ms
[4.056s][info][gc] GC(2) Pause Young (G1 Evacuation Pause) 1105M->1106M(4096M) 776.229ms
[5.561s][info][gc] GC(3) Pause Young (G1 Evacuation Pause) 1552M->1554M(4096M) 771.033ms
[6.332s][info][gc] GC(4) Pause Young (G1 Evacuation Pause) 1732M->1733M(4096M) 557.217ms
[6.899s][info][gc] GC(5) Pause Initial Mark (G1 Humongous Allocation) 1894M->1896M(4096M) 422.604ms
[6.899s][info][gc] GC(6) Concurrent Cycle
[8.534s][info][gc] GC(7) Pause Young (G1 Evacuation Pause) 2476M->2477M(4096M) 569.203ms
[9.226s][info][gc] GC(8) Pause Young (G1 Evacuation Pause) 2655M->2656M(4096M) 490.367ms
[12.341s][info][gc] GC(6) Pause Remark 2758M->2758M(4096M) 1.318ms
[13.057s][info][gc] GC(6) Pause Cleanup 2758M->2212M(4096M) 2.659ms
[13.173s][info][gc] GC(6) Concurrent Cycle 6273.724ms

real	0m13.399s
user	0m29.455s
sys	0m2.855s

JDK9-Parallel

time java -XX:+UseParallelOldGC -Xms4G -Xmx4G -Xlog:gc Case3
[0.024s][info][gc] Using Parallel
[1.591s][info][gc] GC(0) Pause Young (Allocation Failure) 878M->714M(3925M) 892.647ms
[3.270s][info][gc] GC(1) Pause Young (Allocation Failure) 1738M->1442M(3925M) 1371.100ms

real	0m3.644s
user	0m7.956s
sys	0m1.088s

JDK9-Concurrent Mark Sweep

time java -XX:+UseConcMarkSweepGC -Xms4G -Xmx4G -Xlog:gc Case3
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[0.026s][info][gc] Using Concurrent Mark Sweep
[1.661s][info][gc] GC(0) Pause Young (Allocation Failure) 259M->231M(4062M) 1361.996ms
[2.293s][info][gc] GC(1) Pause Young (Allocation Failure) 497M->511M(4062M) 563.307ms
[2.974s][info][gc] GC(2) Pause Young (Allocation Failure) 777M->851M(4062M) 623.093ms
[3.527s][info][gc] GC(3) Pause Young (Allocation Failure) 1117M->1161M(4062M) 502.224ms
[4.807s][info][gc] GC(4) Pause Young (Allocation Failure) 1694M->1828M(4062M) 1038.882ms
[6.565s][info][gc] GC(5) Pause Young (Allocation Failure) 2094M->2364M(4062M) 1688.745ms
[6.580s][info][gc] GC(6) Pause Initial Mark 2369M->2369M(4062M) 14.197ms
[6.580s][info][gc] GC(6) Concurrent Mark
[9.074s][info][gc] GC(7) Pause Young (Allocation Failure) 3031M->3166M(4062M) 1581.572ms
[15.418s][info][gc] GC(6) Concurrent Mark 8838.424ms
[15.418s][info][gc] GC(6) Concurrent Preclean
[15.485s][info][gc] GC(6) Concurrent Preclean 67.031ms
[15.486s][info][gc] GC(6) Concurrent Abortable Preclean
[15.486s][info][gc] GC(6) Concurrent Abortable Preclean 0.126ms
[15.718s][info][gc] GC(6) Pause Remark 3390M->3390M(4062M) 232.467ms
[15.719s][info][gc] GC(6) Concurrent Sweep
[16.728s][info][gc] GC(6) Concurrent Sweep 1009.828ms
[16.728s][info][gc] GC(6) Concurrent Reset
[16.744s][info][gc] GC(6) Concurrent Reset 15.565ms

real	0m17.045s
user	0m29.167s
sys	0m4.394s

OpenJDK11-Shenandoah

time java -XX:+UseShenandoahGC -Xms4G -Xmx4G -Xlog:gc Case3
[0.006s][info][gc] Min heap equals to max heap, disabling ShenandoahUncommit
[0.012s][info][gc] Heuristics ergonomically sets -XX:+ExplicitGCInvokesConcurrent
[0.012s][info][gc] Heuristics ergonomically sets -XX:+ShenandoahImplicitGCInvokesConcurrent
[0.013s][info][gc] Using Shenandoah
[0.894s][info][gc] Trigger: Learning 1 of 5. Free (2860M) is below initial threshold (2867M)
[0.896s][info][gc] GC(0) Concurrent reset 0.560ms
[1.062s][info][gc] GC(0) Pause Init Mark (process weakrefs) 0.634ms
[3.511s][info][gc] Cancelling GC: Stopping VM
[3.511s][info][gc] GC(0) Concurrent marking (process weakrefs) 2449.346ms

real	0m3.760s
user	0m3.191s
sys	0m1.752s

JDK17-Epsilon

time java -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xms4G -Xmx4G  -Xlog:gc Case3
[0.004s][info][gc] Using Epsilon
[0.005s][warning][gc,init] Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups
[0.199s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 205M (5.01%) used
[0.314s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 453M (11.07%) used
[0.442s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 676M (16.51%) used
[0.639s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 1014M (24.77%) used
[0.918s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 1222M (29.85%) used
[0.941s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 1517M (37.06%) used
[1.483s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 1725M (42.14%) used
[1.660s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 2274M (55.54%) used
[2.102s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 2482M (60.62%) used
[2.287s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 2690M (65.70%) used
[2.340s][info   ][gc     ] Heap: 4096M reserved, 4096M (100.00%) committed, 2730M (66.67%) used

real	0m2.551s
user	0m1.307s
sys	0m1.030s

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2309299.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

uniapp-原生android插件开发摘要

uni-app在App侧的原生扩展插件&#xff0c;支持使用java、object-c等原生语言编写&#xff0c;从HBuilderX 3.6起&#xff0c;新增支持了使用uts来开发原生插件。 基础项目 UniPlugin-Hello-AS工程请在App离线SDK中查找 基础项目(App离线SDK)已经配置好了自定义插件所需要的…

派可数据BI接入DeepSeek,开启智能数据分析新纪元

派可数据BI产品完成接入DeepSeek&#xff0c;此次接入标志着派可数据BI在智能数据分析领域迈出了重要一步&#xff0c;将为用户带来更智能、更高效、更便捷的数据分析体验。 派可数据BI作为国内领先的商业智能解决方案提供商&#xff0c;一直致力于为用户提供高效、稳定易扩展…

M4 Mac mini运行DeepSeek-R1模型

前言 最近DeepSeek大模型很火&#xff0c;实际工作中也有使用&#xff0c;很多人觉得需要很好的显卡才能跑起来&#xff0c;至少显存需要很高&#xff0c;但实际上一般的核显机器也能跑起来&#xff0c;只不过内存要求要大&#xff0c;对于个人而言&#xff0c;实际上Mac M芯片…

MaxKB上架至阿里云轻量应用服务器镜像市场

近日&#xff0c;MaxKB开源知识库问答系统已上架至阿里云轻量应用服务器镜像市场&#xff0c;目前是阿里云此类镜像市场中唯一推荐的AI应用镜像。 ▲图1 MaxKB已经上架至阿里云轻量应用服务器镜像市场 MaxKB是飞致云旗下开源项目&#xff0c;是一款基于大语言模型和RAG&…

[KEIL]单片机技巧 01

1、查看外设寄存器的值 配合对应的芯片开发手册以查看寄存器及其每一位的意义&#xff0c;可以解决90%以上的单纯的片内外设bug&#xff0c;学会如何通过寄存器的值来排外设上的蛊是嵌入式开发从小白到入门的重要一步&#xff0c;一定要善于使用这个工具&#xff0c;而不是外设…

【网络安全 | 渗透测试】GraphQL精讲二:发现API漏洞

未经许可,不得转载。 推荐阅读:【网络安全 | 渗透测试】GraphQL精讲一:基础知识 文章目录 GraphQL API 漏洞寻找 GraphQL 端点通用查询常见的端点名称请求方法初步测试利用未清理的参数发现模式信息使用 introspection探测 introspection运行完整的 introspection 查询可视化…

MySQL练习

将安装包下载并上传 方法一 步骤 创建组与用户 [rootlocalhost ~]# groupadd mysql [rootlocalhost ~]# useradd -r -g mysql -s /bin/false mysql 解压安装包 [rootlocalhost ~]# tar xf mysql-8.0.36-linux-glibc2.28-x86_64.tar.xz -C /usr/local/软连接 [rootlocalh…

【动手实验】TCP半连接队列、全连接队列实战分析

本文是对 从一次线上问题说起&#xff0c;详解 TCP 半连接队列、全连接队列 这篇文章的实验复现和总结&#xff0c;借此加深对 TCP 半连接队列、全连接队列的理解。 实验环境 两台腾讯云服务器 node2&#xff08;172.19.0.12&#xff09; 和 node3&#xff08;172.19.0.15&am…

【六祎 - Note】SQL备忘录;DDL,DML,DQL,DCL

SQL备忘录 from to : 点击访问源地址

智能AI替代专家系统(ES)、决策支持系统(DSS)?

文章目录 前言一、专家系统&#xff08;ES&#xff09;是什么&#xff1f;二、决策支持系统&#xff08;DSS&#xff09;是什么&#xff1f;1.决策支持系统定义2.决策系统的功能与特点3.决策支持系统的组成 三、专家系统&#xff08;ES&#xff09;与决策支持系统&#xff08;D…

比较Spring AOP和AspectJ

1. 介绍 当前有多个可用的AOP库&#xff0c;这些库必须能够回答许多问题&#xff1a; 它与我现有的或新的应用程序兼容吗&#xff1f;在哪里可以实施AOP&#xff1f;它与我的应用程序集成的速度有多快&#xff1f;性能开销是多少&#xff1f; 在本文中&#xff0c;我们将着眼…

现今大语言模型性能(准确率)比较

现今大语言模型性能(准确率)比较 表头信息:表的标题为“大语言模型性能比较结果”(英文:Table 1: Large Language Model Performance Comparison Results),表明该表是用于对比不同大语言模型的性能。列信息: 模型:列出参与比较的不同大语言模型名称,包括LLAMA3(70B)…

(十 五)趣学设计模式 之 命令模式!

目录 一、 啥是命令模式&#xff1f;二、 为什么要用命令模式&#xff1f;三、 策略模式的实现方式四、 命令模式的优缺点五、 命令模式的应用场景六、 总结 &#x1f31f;我的其他文章也讲解的比较有趣&#x1f601;&#xff0c;如果喜欢博主的讲解方式&#xff0c;可以多多支…

React低代码项目:问卷编辑器 I

问卷编辑器 Date: February 20, 2025 4:17 PM (GMT8) 目标 完成问卷编辑器的设计和开发完成复杂系统的 UI 组件拆分完成复杂系统的数据结构设计 内容 需求分析技术方案设计开发 注意事项&#xff1a; 需求指导设计&#xff0c;设计指导开发。前两步很重要页面复杂的话&…

信刻光盘安全隔离与信息交换系统让“数据摆渡”安全高效

随着数据传输、存储及信息技术的飞速发展&#xff0c;信息安全保护已成为重中之重。各安全领域对跨网数据交互的需求日益迫切&#xff0c;数据传输的安全可靠性成为不可忽视的关键。为满足业务需求并遵守保密规范&#xff0c;针对于涉及重要秘密信息&#xff0c;需做到安全的物…

【项目管理】基于 C 语言的 QQ 聊天室实现(TCP + 多线程 + SQLite3)

基于 C 语言的 QQ 聊天室(TCP + 多线程 + SQLite3) 项目功能基础功能: 登录、注册、添加好友、私聊、创建群聊、群聊扩展功能: 删除好友、注销账号、好友在线状态、群管理(拉人/踢人)、VIP 特权、邮件通知等 功能介绍:模拟QQ聊天客户端:登录界面:1、登录2、注册 //将用…

力扣27.移除元素(双指针)

题目看起来很乱&#xff0c;实际上意思是&#xff1a;把数组中值不等于val的元素放在下标为0,1,2,3......&#xff0c;并且返回数组中值不等于val的元素的个数 方法一&#xff1a;直接判断覆盖 class Solution { public:int removeElement(vector<int>& nums, int…

VADv2: 基于矢量表征和概率规划的E2E架构

1. 写在前面 今天分享一篇自动驾驶领域的论文VADv2(End-to-End Vectorized Autonomous Driving via Probabilistic Planning), 基于矢量表征和概率规划的E2E架构,2024年2月份华中科技大和地平线合作的一篇文章, 在经典的端到端模型架构上作出了基于概率规划去输出规划轨迹的…

机器学习:强化学习的epsilon贪心算法

强化学习&#xff08;Reinforcement Learning, RL&#xff09;是一种机器学习方法&#xff0c;旨在通过与环境交互&#xff0c;使智能体&#xff08;Agent&#xff09;学习如何采取最优行动&#xff0c;以最大化某种累积奖励。它与监督学习和无监督学习不同&#xff0c;强调试错…

计算机毕业设计SpringBoot+Vue.js基于JAVA语言的在线考试与学习交流网页平台(源码+文档+PPT+讲解)

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…