Java虚拟机打印GC垃圾回收信息

    xiaoxiao2022-07-02  116

    设置参数如下:

     

    public class HeapOOM { public static void main(String[] args) { /** * VM options:-Xms5m -Xmx5m -XX:+PrintGCDetails * * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space */ // String[] strings = new String[100 * 1000 * 1000]; /** * VM options:-Xms5m -Xmx5m -XX:+PrintGCDetails * * java.lang.OutOfMemoryError: GC overhead limit exceeded */ List<Object> list = new LinkedList<>(); int i = 0; while (true) { i++; if (i % 10000 == 0) System.out.println("i = " + i); list.add(new Object()); } } }

     

    最新回复(0)