当前位置:网站首页>【大型电商项目开发】性能压测-性能监控-堆内存与垃圾回收-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 分析,线程分析…
运行:正在运行的
休眠:sleep
等待:wait
驻留:线程池里面的空闲线程
监视:阻塞的线程,正在等待锁
3)安装插件方便查看垃圾回收(gc)
- 工具->插件
- 可用插件->检查版本更新
- 如果 503 错误解决:
打开网址https://visualvm.github.io/pluginscenters.html
cmd 查看自己的 jdk 版本,找到对应的 - 复制下面查询出来的链接。并重新设置上即可
- 下载gc插件
- 查看gc
边栏推荐
- 资深测试/开发程序员写下无bug?资历(枷锁)不要惧怕错误......
- 【selenium自动化】常用注解
- Basic operations of database and table ----- delete index
- 《论文笔记》Multi-UAV Collaborative Monocular SLAM
- 2022.07.03 (LC 6108 decryption message)
- Senior Test / development programmers write no bugs? Qualifications (shackles) don't be afraid of mistakes
- 【纯音听力测试】基于MATLAB的纯音听力测试系统
- [untitled]
- Playwright recording
- Liangzai's first program life and annual summary in 2022
猜你喜欢
【C】(笔试题)指针与数组,指针
Les phénomènes de « salaire inversé » et de « remplacement des diplômés » indiquent que l'industrie des tests a...
[STM32] (I) overview and GPIO introduction
Pycharm professional download and installation tutorial
【纯音听力测试】基于MATLAB的纯音听力测试系统
Basic operation of database and table ----- the concept of index
1189. Maximum number of "balloons"
Grabbing and sorting out external articles -- status bar [4]
dotnet-exec 0.6.0 released
Parameter passing mechanism of member methods
随机推荐
Implementation steps of master detail detail layout mode of SAP ui5 application
Chia Tai International Futures: what is the master account and how to open it?
LeetCode周赛 + AcWing周赛(T4/T3)分析对比
skimage: imread & imsave & imshow
(script) one click deployment of any version of redis - the way to build a dream
[wave modeling 2] three dimensional wave modeling and wave generator modeling matlab simulation
【纯音听力测试】基于MATLAB的纯音听力测试系统
[circuit design] optocoupler use and circuit design summary
Intel sapphire rapids SP Zhiqiang es processor cache memory split exposure
《论文笔记》Multi-UAV Collaborative Monocular SLAM
揭露测试外包公司,关于外包,你或许听到过这样的声音
lambda表达式
Playwright之录制
Discrete mathematics: reasoning rules
Compare whether two lists are equal
Several simplified forms of lambda expression
Research Report on the overall scale, major producers, major regions, products and application segmentation of agricultural automatic steering system in the global market in 2022
资深测试/开发程序员写下无bug?资历(枷锁)不要惧怕错误......
Distributed base theory
【C】(笔试题)指针与数组,指针