【发布时间】:2020-04-15 09:00:24
【问题描述】:
伙计们,这可能是一个愚蠢的问题,但我自己无法处理。所以,我试图在 Netbeans 10 中为一个类应用 VM 参数(它来自我正在阅读的教程):
public class GCDemo {
// 8.4MB approx. (2M entries * 4b)
static final int[] iArray = new int[2*1024*1024];
public static void main(String[] a) {
}
}
当我运行这个类时,一切正常。这是输出:
Heap
def new generation total 4288K, used 632K [0x00000000ff200000,
0x00000000ff6a0000, 0x00000000ff6a0000)
eden space 3840K, 16% used [0x00000000ff200000, 0x00000000ff29e3b0,
0x00000000ff5c0000)
from space 448K, 0% used [0x00000000ff5c0000, 0x00000000ff5c0000,
0x00000000ff630000)
to space 448K, 0% used [0x00000000ff630000, 0x00000000ff630000,
0x00000000ff6a0000)
tenured generation total 9600K, used 8192K [0x00000000ff6a0000,
0x0000000100000000, 0x0000000100000000)
the space 9600K, 85% used [0x00000000ff6a0000, 0x00000000ffea0010,
0x00000000ffea0200, 0x0000000100000000)
Metaspace used 2537K, capacity 4486K, committed 4864K,
reserved 1056768K
class space used 274K, capacity 386K, committed 512K, reserved
1048576K
BUILD SUCCESSFUL (total time: 0 seconds)
但是对于另一个类,在同一个包中称为 Test:
public class Test {
public static void main(String[] args) {
System.out.println("TEST");
}
}
输出在命令行中显示TEST,但也显示了上述类GCDemo
的运行配置这是Test类的输出:
TEST
Heap
def new generation total 4288K, used 632K [0x00000000ff200000,
0x00000000ff6a0000, 0x00000000ff6a0000)
eden space 3840K, 16% used [0x00000000ff200000, 0x00000000ff29e3b0,
0x00000000ff5c0000)
from space 448K, 0% used [0x00000000ff5c0000, 0x00000000ff5c0000,
0x00000000ff630000)
to space 448K, 0% used [0x00000000ff630000, 0x00000000ff630000,
0x00000000ff6a0000)
tenured generation total 9600K, used 0K [0x00000000ff6a0000,
0x0000000100000000, 0x0000000100000000)
the space 9600K, 0% used [0x00000000ff6a0000, 0x00000000ff6a0000,
0x00000000ff6a0200, 0x0000000100000000)
Metaspace used 2538K, capacity 4486K, committed 4864K,
reserved 1056768K
class space used 274K, capacity 386K, committed 512K, reserved
1048576K
我做错了什么?如何只为GCDemo类指定运行配置?
【问题讨论】:
标签: java netbeans garbage-collection arguments