当前位置:网站首页>在线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文件
边栏推荐
- 广域铭岛入选2022年重庆市数字经济产业发展试点示范项目名单
- 还在纠结报表工具的选型么?来看看这个
- mysql在cmd的登录及数据库与表的基本操作
- Qt 支持HEIC/HEIF格式图片
- Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions
- What are the common API security flaws?
- 报告:想学AI的学生数量已涨200%,老师都不够用了
- The first experience of Shengsi large model experience platform——Take the small model LeNet as an example
- 基于ModelArts的物体检测YOLOv3实践【玩转华为云】
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(1)开发概要
猜你喜欢
小程序毕设作品之微信美食菜谱小程序毕业设计成品(2)小程序功能
Change Servlet project to SSM project
shell脚本------条件测试 if语句和case分支语句
基于CAP组件实现补偿事务与消息幂等性
如何在IntellJ IDEA中批量修改文件换行符
退役划水
企业微信群:机器人定时提醒功能数据库配置化
Drawing arrows of WPF screenshot control (5) "Imitation WeChat"
SAP ABAP OData 服务如何支持 $orderby (排序)操作试读版
How programmers learn open source projects, this article tells you
随机推荐
Endorsed in 2022 years inventory | product base, science and technology, guangzhou automobile group striding forward
AI篮球裁判火了,走步算得特别准,就问哈登慌不慌
redis
Android 安全与防护策略
[Cloud Residency Co-Creation] Huawei Cloud Global Scheduling Technology and Practice of Distributed Technology
Go-Excelize API source code reading (8) - GroupSheets(sheets []string), UngroupSheets()
July 31, 2022 -- Take your first steps with C# -- Use arrays and foreach statements in C# to store and iterate through sequences of data
Android Security and Protection Policy
MacOS下postgresql(pgsql)数据库密码为什么不需要填写或可以乱填写
微信公众号授权登录后报redirect_uri参数错误的问题
STM32 Personal Notes - Embedded C Language Optimization
复现assert和eval成功连接或失败连接蚁剑的原因
C#/VB.NET 将PPT或PPTX转换为图像
什么是步进电机?40张图带你了解!
DBPack SQL Tracing 功能及数据加密功能详解
Small application project works WeChat gourmet recipes applet graduation design of finished product (1) the development profile
Dataset之mpg:mpg数据集的简介、下载、使用方法之详细攻略
Qt supports HEIC/HEIF format images
如何在IntellJ IDEA中批量修改文件换行符
Explain / Desc execution plan analysis