Skip to content

Instantly share code, notes, and snippets.

@liuxinglanyue
Last active August 29, 2015 14:21
Show Gist options
  • Save liuxinglanyue/90ab9f18177e643c142e to your computer and use it in GitHub Desktop.
Save liuxinglanyue/90ab9f18177e643c142e to your computer and use it in GitHub Desktop.
MAT工具分析OOM例子
//java -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio=8 -XX:PermSize=32M -XX:MaxPermSize=64M -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -Xloggc:oom.log HeapOOM
import java.util.*;
public class HeapOOM {
public static void main(String[] args) {
List list = new ArrayList();
int count = 0;
while(true) {
count++;
OOMObject o = new OOMObject("objname" + count);
if(count%10000==0) {
System.out.println(count);
}
list.add(o);
}
}
}
public class OOMObject {
private String objname;
public OOMObject(String objname) {
this.objname = objname;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment