当前位置:网站首页>【大型电商项目开发】性能压测-性能监控-堆内存与垃圾回收-39
【大型电商项目开发】性能压测-性能监控-堆内存与垃圾回收-39
2022-07-05 01:00:00 【随意石光】
一:性能监控之jvm内存模型

1.程序计数器 Program Counter Register
- 记录的是正在执行的虚拟机字节码指令的地址,
- 此内存区域是唯一一个在JAVA虚拟机规范中没有规定任何OutOfMemoryError的区域
2.虚拟机 VM Stack
- 描述的是 JAVA 方法执行的内存模型,每个方法在执行的时候都会创建一个栈帧, 用于存储局部变量表,操作数栈,动态链接,方法接口等信息
- 局部变量表存储了编译期可知的各种基本数据类型、对象引用
- 线程请求的栈深度不够会报 StackOverflowError 异常
- 栈动态扩展的容量不够会报 OutOfMemoryError 异常
- 虚拟机栈是线程隔离的,即每个线程都有自己独立的虚拟机栈
3.本地方法 Native Stack
- 本地方法栈类似于虚拟机栈,只不过本地方法栈使用的是本地方法
4.堆 Heap
- 几乎所有的对象实例都在堆上分配内存

二:堆
所有的对象实例以及数组都要在堆上分配。堆是垃圾收集器管理的主要区域,也被称为“GC 堆”;也是我们优化最多考虑的地方。 堆可以细分为:
1.新生代:Eden 空间 、From Survivor 空间、To Survivor 空间
2.老年代
3.永久代/元空间:Java8 以前永久代,受 jvm 管理,java8 以后元空间,直接使用物理内存。因此, 默认情况下,元空间的大小仅受本地内存限制。

从 Java8 开始,HotSpot 已经完全将永久代(Permanent Generation)移除,取而代之的是一 个新的区域—元空间(MetaSpace)

- 对象创建后,先去新生代区,如果放不下,则取GC垃圾回收。再去新生代区,如果还是放不下,就去老年区
- 老年区是新生代区无法处理的情况下,才会进去。如果老年区可以放下,则分配内存。如果还是放不下,就进行全面GC
- 如果还是放不下,则会报内存溢出异常
- 老年区一般存放生命力持久的对象以及大对象
- Eden园区能放进幸存者区就放进去,放不进去就放进老年区
三:jconsole 与 jvisualvm(可监控本地和远程应用)
Jdk 的两个小工具 jconsole、jvisualvm(升级版的 jconsole);通过命令行启动,可监控本地和 远程应用。远程应用需要配置
1.jconsole
1)进入jconsole
win+r进入cmd,输入jconsole
双击需要连接的服务
2)查看监控信息
2.jvisualvm(推荐使用)
1)启动
win+r进入cmd,输入jvisualvm
2)jvisualvm 能干什么
监控内存泄露,跟踪垃圾回收,执行时内存、cpu 分析,线程分析…![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SfBQfgzm-1656760038856)(https://img-blog.cdnimg.cn/e4897ddc7b9a4c00895c6720de838f8e.png)]](/img/7a/df181ad25731b017274a7de6efa8b4.png)
运行:正在运行的
休眠:sleep
等待:wait
驻留:线程池里面的空闲线程
监视:阻塞的线程,正在等待锁
3)安装插件方便查看垃圾回收(gc)
- 工具->插件

- 可用插件->检查版本更新

- 如果 503 错误解决:
打开网址https://visualvm.github.io/pluginscenters.html
cmd 查看自己的 jdk 版本,找到对应的
- 复制下面查询出来的链接。并重新设置上即可

- 下载gc插件

- 查看gc

边栏推荐
- SAP UI5 应用的主-从-从(Master-Detail-Detail)布局模式的实现步骤
- Huawei employs millions of data governance experts! The 100 billion market behind it deserves attention
- Getting started with Paxos
- 创新引领方向 华为智慧生活全场景新品齐发
- 整理混乱的头文件,我用include what you use
- 【海浪建模1】海浪建模的理论分析和matlab仿真
- Pandora IOT development board learning (RT thread) - Experiment 4 buzzer + motor experiment [key external interrupt] (learning notes)
- Hologres query management and timeout processing
- 全网最全正则实战指南,拿走不谢
- MySQL uses the explain tool to view the execution plan
猜你喜欢

lambda表达式

Relationship between classes and objects

资深测试/开发程序员写下无bug?资历(枷锁)不要惧怕错误......

【Unity】InputSystem

Expose testing outsourcing companies. You may have heard such a voice about outsourcing

Talking about JVM 4: class loading mechanism

Hill sort of sorting

Complete knapsack problem (template)

Identifiers and keywords

What if the programmer's SQL data script coding ability is weak and Bi can't do it?
随机推荐
华为百万聘请数据治理专家!背后的千亿市场值得关注
Two numbers replace each other
Hill sort of sorting
Chia Tai International Futures: what is the master account and how to open it?
Open3d uses GICP to register point clouds
[wave modeling 1] theoretical analysis and MATLAB simulation of wave modeling
Oracle case: SMON rollback exception causes instance crash
视频网站手绘
Pycharm professional download and installation tutorial
Binary conversion problem
Leetcode70 (Advanced), 322
Query for Boolean field as "not true" (e.g. either false or non-existent)
两个数相互替换
Hand drawn video website
【海浪建模1】海浪建模的理论分析和matlab仿真
Ruby tutorial
SAP ui5 application development tutorial 106 - how to improve the readability of SAP ui5 application routing URL trial version
Inventory of more than 17 typical security incidents in January 2022
TS quick start - functions
College degree, what about 33 year old Baoma? I still sell and test, and my monthly income is 13K+