当前位置:网站首页>在线GC日志分析工具——GCeasy
在线GC日志分析工具——GCeasy
2022-08-01 10:19:00 【正在学习编程的小学生】
1.GCeasy
地址:gceasy
2.模拟堆内存不足
2.1代码引入
jvm配置
-Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:D:/Desktop/GCLogTest.log
import java.util.ArrayList;
/** * 测试生成详细的日志文件 * * -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC */
public class GCLogTest {
public static void main(String[] args) {
ArrayList<byte[]> list = new ArrayList<>();
for (int i = 0; i < 5000; i++) {
byte[] arr = new byte[1024 * 50];//50KB
list.add(arr);
try {
Thread.sleep(30);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
2.2运行代码生成log文件
2.3上传log文件
3.模拟元空间异常
3.1代码引入
JVM配置
-Xms60m -Xmx60m -XX:MetaspaceSize=10m -XX:MaxMetaspaceSize=10m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:D:/Desktop/MetaspaceOOM.log
import com.sun.xml.internal.ws.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;
/** * java.lang.OutOfMemoryError: Metaspace异常演示: * * -Xms60m -Xmx60m -XX:MetaspaceSize=10m -XX:MaxMetaspaceSize=10m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC * */
public class MetaspaceOOM extends ClassLoader {
public static void main(String[] args) {
int j = 0;
try {
MetaspaceOOM test = new MetaspaceOOM();
for (int i = 0; i < 10000; i++) {
//创建ClassWriter对象,用于生成类的二进制字节码
ClassWriter classWriter = new ClassWriter(0);
//指明版本号,修饰符,类名,包名,父类,接口
classWriter.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, "Class" + i, null, "java/lang/Object", null);
//返回byte[]
byte[] code = classWriter.toByteArray();
//类的加载
test.defineClass("Class" + i, code, 0, code.length);//Class对象
j++;
}
} finally {
System.out.println(j);
}
}
}
3.2运行代码生成log文件
3.3上传log文件
边栏推荐
- 解决new Thread().Start导致高并发CPU 100%的问题
- 还在纠结报表工具的选型么?来看看这个
- How I secured 70,000 ETH and won a 6 million bug bounty
- CTO strongly banning the use of the Calendar, that in what?
- 利用正则表达式的回溯实现绕过
- Push the local project to the remote repository
- 深度学习 | MATLAB实现GRU门控循环单元gruLayer参数设定
- Introduction and application of pointers
- Golang内存分析工具gctrace和pprof实战
- notes....
猜你喜欢
随机推荐
notes....
retired paddling
MySQL 必现之死锁
基于CAP组件实现补偿事务与消息幂等性
编码解码(btoa、encodeURIComponent、encodeURI、escape)
50.【动态二维数组的运用】
CTFshow,命令执行:web32
周鸿祎称微软抄袭 360 安全模式后发文否认;英特尔CEO基辛格回应市值被AMD超越:股价下跌是咎由自取|极客头条
CTO strongly banning the use of the Calendar, that in what?
C#/VB.NET 将PPT或PPTX转换为图像
[Software Architecture Mode] The difference between MVVM mode and MVC mode
RK3399平台开发系列讲解(内核入门篇)1.52、printk函数分析 - 其函数调用时候会关闭中断
机器学习 | MATLAB实现支持向量机回归RegressionSVM参数设定
【cartographer ros】十: 延时和误差分析
Introduction to ADAS
xss-labs靶场挑战
C language game - minesweeper
STM32入门开发 介绍IIC总线、读写AT24C02(EEPROM)(采用模拟时序)
Introduction and application of heap memory (including examples)
Comprehensive experiment BGP