Last active
August 29, 2015 14:21
-
-
Save liuxinglanyue/90ab9f18177e643c142e to your computer and use it in GitHub Desktop.
MAT工具分析OOM例子
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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