在 JConsole 下观察到的以下代码显示了堆大小的不断增加。堆达到最大 25mb,然后 GC 运行并将堆大小减小到近 3MB。这是预期的行为吗?我很惊讶!
public class Dummy {
public static void main(String[] args) {
System.out.println("start");
while(true){
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
我正在使用雪豹。