/**
 * -Xms20M -Xmx20M
 * @author 
 *
 */
public class HeapOOM {
    
    static class OOMObject {
        
    }
    public static void main(String[] args) {
        List<OOMObject> list = new ArrayList<OOMObject>();
        
        while(true) {
            list.add(new OOMObject());
        }

    }

}

启动参数 -XX:+HeapDumpOnOutOfMemoryError

如果发生内存泄露和内存溢出,就会在根目录上生成***.hprof文件

通过内存分析工具Eclipse Memory Analysis Tools (MAT),就可以对内存进行分析 

相关文章:

  • 2021-07-30
  • 2022-12-23
  • 2021-06-23
  • 2022-01-15
  • 2022-12-23
猜你喜欢
  • 2021-08-21
  • 2021-12-23
  • 2022-12-23
  • 2021-07-01
  • 2021-10-03
  • 2021-11-28
相关资源
相似解决方案