当前位置:网站首页>JVM uses tools to analyze classic cases of OOM
JVM uses tools to analyze classic cases of OOM
2022-06-25 13:59:00 【Resounding through heaven】
1 Heap overflow
1.1 JVM Parameters
-XX:+PrintGCDetails -XX:MetaspaceSize=64m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=heap/heapdump.hprof -XX:+PrintGCDateStamps -Xloggc:logs/gc-oomHeap.log -Xms30M -Xmx30M
1.2 CODE
/** * @Description: -XX:+PrintGCDetails -XX:MetaspaceSize=64m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=heap/heapdump.hprof -XX:+PrintGCDateStamps -Xloggc:logs/gc-oomHeap.log -Xms30M -Xmx30M * * * PrintGCDetails: Print GC details * MetaspaceSize: Meta space size is 64m * HeapDumpOnOutOfMemoryError、HeapDumpPath: Generate dump file * -XX:+PrintGCDateStamps -Xloggc:logs/gc-oomHeap.log: GC Plus time 、GC Generate logs * -Xms30M -Xmx30M: Heap space size * * * * @Author: rosh * @Date: 2022/6/22 22:10 */
public class HeapOomTest {
public static void main(String[] args) {
List<People> list = new ArrayList<>();
while (true) {
list.add(new People());
}
}
}
1.3 result

1.4 analysis GC journal
# Visit website , choice GC journal
https://gceasy.io/


1.5 VisualVM analysis dump file



1.6 Solutions
1、 Check for large object assignments , The most likely is large array allocation
2、 adopt jmap command , Put the heap memory dump Come down , Use MAT Wait for tools to analyze , Check for memory leaks
3、 If no memory leak is found , Use -Xmx Increase heap memory
2 Meta space overflow
2.1 Parameters
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:log/gc-oomMeta.log -XX:MetaspaceSize=40m -XX:MaxMetaspaceSize=40m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=heap/heapdumpMeta.hprof -Xms60M -Xmx60M
2.2 CODE
/** * @Description: -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:log/gc-oomMeta.log -XX:MetaspaceSize=40m -XX:MaxMetaspaceSize=40m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=heap/heapdumpMeta.hprof -Xms60M -Xmx60M * * GC Log correlation :-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:logs/gc-oomMeta.log * Meta space size setting :-XX:MetaspaceSize=40m -XX:MaxMetaspaceSize=40m * Pile up dump file :-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=heap/heapdumpMeta.hprof * -Xms60M -Xmx60M: Heap size settings * * @Author: rosh * @Date: 2022/6/22 22:57 */
public class MetaspaceOomTest {
public static void main(String[] args) {
while (true) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(People.class);
enhancer.setUseCache(false);
enhancer.setCallback((MethodInterceptor) (o, method, params, methodProxy) -> {
System.out.println(" I've enhanced ,JAVA Can save the Chinese people ");
return methodProxy.invokeSuper(o, params);
});
People people = (People) enhancer.create();
people.sayHello();
}
}
}
2.3 result

2.4 VisualVM see

2.5 see dump



2.6 Solution
1. Check whether the permanent generation space or meta space is set too small
2. Check if there are a lot of reflection operations in the code
3. dump After through mat Check if there are a large number of proxy classes generated by reflection
边栏推荐
- Openstack learning notes -nova component insight
- Asp.net WebForm使用NPOI导出Excel
- [proteus simulation] 51 MCU +ds1302+lcd1602 display
- leetcode:456. 132 mode [monotone stack]
- ‘nvidia-smi‘ 不是内部或外部命令,也不是可运行的程序或批处理文件
- 打新债是不是不安全
- QT memory mapping
- Openstack learning notes -grace component insight
- Windows下MySQL的安装和删除
- As a software testing engineer, how do you think to ensure software quality?
猜你喜欢

Discuz copy today's headlines template /discuz news and information business GBK template

Beego--- notes

Today in history: Netease was founded; The first consumer electronics exhibition was held; The first webcast in the world

‘nvidia-smi‘ 不是内部或外部命令,也不是可运行的程序或批处理文件

Method for wrapping multiple promise instances into a new promise instance
![[open source Hongmeng system display] the rk3568 development board is equipped with openharmony 3.1 release](/img/c4/0bfb380d38b5205a02a10175ee6888.png)
[open source Hongmeng system display] the rk3568 development board is equipped with openharmony 3.1 release

作为一名软件测试工程师你认为怎么样才能保证软件质量?

深入理解深度神经网络背后的数学(Mysteries of Neural Networks Part I)

關於一道教材題的講解

Network remote access using raspberry pie
随机推荐
启牛是正规的吗?股票开户安全吗?
“移动云杯”算力网络应用创新大赛火热报名中!
阻止深度神经网络过拟合(Mysteries of Neural Networks Part II)
Is qiniu regular? Is it safe to open a stock account?
sql导入这样怎么解决
Test your earning power? What will you do in the future?
Is it safe for tongdaxin to open a stock account
How to determine if a web worker has been created or closed
Syntax 'trap'
golang项目依赖管理工具go vendor,go mod
JVM 用工具分析OOM经典案例
Application of tactile intelligent sharing-rk3568 in financial self-service terminal
Mise en place d'un Cluster kubernets avec plusieurs serveurs Cloud
sigmoid函数sigmoid求导
How to solve SQL import
Sigmoid function sigmoid derivation
Discuz仿今日头条模板/Discuz新闻资讯商业版GBK模板
Rust,程序員創業的最佳選擇?
Rust, the best choice for programmers to start a business?
Beego--- notes