Java对象不赋值null的必要性及其影响详细说明?
- 内容介绍
- 文章标签
- 相关推荐
本文共计659个文字,预计阅读时间需要3分钟。
首先查看代码,然后配置IDEA以打印GC日志,并运行代码。
javapublic class TestDemo1 { public static void main(String[] args) { if (true) { byte[] placeHolder=new byte[64 * 1024 * 1024]; System.out.println(placeHolder.length / 1024); } System.gc(); }}
配置IDEA打印GC日志:
1.打开IDEA,选择`Run` -> `Edit Configurations...`。
2.在弹出的窗口中,找到并选择`Java Application`。
3.点击`+`添加新的配置,选择`VM options`。
4.在`VM options`中输入以下内容:
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:/path/to/your/gc.log 其中`/path/to/your/gc.log`是你想要存储GC日志的文件路径。5.点击`OK`保存配置。
运行代码,观察IDEA控制台输出和`gc.log`文件中的GC日志。
本文共计659个文字,预计阅读时间需要3分钟。
首先查看代码,然后配置IDEA以打印GC日志,并运行代码。
javapublic class TestDemo1 { public static void main(String[] args) { if (true) { byte[] placeHolder=new byte[64 * 1024 * 1024]; System.out.println(placeHolder.length / 1024); } System.gc(); }}
配置IDEA打印GC日志:
1.打开IDEA,选择`Run` -> `Edit Configurations...`。
2.在弹出的窗口中,找到并选择`Java Application`。
3.点击`+`添加新的配置,选择`VM options`。
4.在`VM options`中输入以下内容:
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:/path/to/your/gc.log 其中`/path/to/your/gc.log`是你想要存储GC日志的文件路径。5.点击`OK`保存配置。
运行代码,观察IDEA控制台输出和`gc.log`文件中的GC日志。

