当前位置:网站首页>在线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文件

边栏推荐
- 自定义类型——枚举、联合
- notes....
- Qt 支持HEIC/HEIF格式图片
- 如何从完美的智能合约中窃取 1 亿美元
- redis
- 50.【Application of dynamic two-dimensional array】
- Introduction to STM32 development Introduce IIC bus, read and write AT24C02 (EEPROM) (using analog timing)
- cisco交换机基本配置命令(华为交换机保存命令是什么)
- Android Security and Protection Policy
- Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions
猜你喜欢

ClickHouse入门介绍与其特性

如何在IntellJ IDEA中批量修改文件换行符

阿里腾讯面试一二

Qt supports HEIC/HEIF format images

50.【Application of dynamic two-dimensional array】

CTO strongly banning the use of the Calendar, that in what?

STM32 Personal Notes - Watchdog
retired paddling

Endorsed in 2022 years inventory | product base, science and technology, guangzhou automobile group striding forward

The use of scrapy crawler framework
随机推荐
怎么找出电脑隐藏的软件(如何清理电脑隐藏软件)
Android Security and Protection Policy
July 31, 2022 -- Take your first steps with C# -- Use arrays and foreach statements in C# to store and iterate through sequences of data
【cartographer ros】十: 延时和误差分析
开天aPaaS之移动手机号码空号检测【开天aPaaS大作战】
Google Earth Engine APP——15行代码搞定一个inspector高程监测APP
我是如何保护 70000 ETH 并赢得 600 万漏洞赏金的
CTO strongly banning the use of the Calendar, that in what?
编码解码(btoa、encodeURIComponent、encodeURI、escape)
利用正则表达式的回溯实现绕过
Custom Types - Enums, Unions
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (4) Opening Report
Yang Hui Triangle (C language implementation)
C language game - minesweeper
2022年7月31日--使用C#迈出第一步--使用 C# 创建具有约定、空格和注释的易读代码
xss漏洞学习
What are the common API security flaws?
DBPack SQL Tracing 功能及数据加密功能详解
retired paddling
WPF 截图控件之绘制箭头(五)「仿微信」