/**
* Copyright description
*/
package overload;
import java.util.HashSet;
/**
* To Add descript here
*测试outMemory是否可以捕捉
* @author think
* @since 2012-1-14
*/
public class OutMemory {
/**
* Methods description
*
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
long t = 0;
try{
HashSet total = new HashSet(1000000);
for(;;){
System.out.println("["+(t++)+"]");
HashSet ss = new HashSet(1000000);
ss.add(new Object());
total.add(ss);
}
}catch(Exception e){
e.printStackTrace();
}
}
}
平台打印的东东
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.<init>(Unknown Source)
at java.util.HashMap.<init>(Unknown Source)
at java.util.HashSet.<init>(Unknown Source)
at overload.OutMemory.main(OutMemory.java:28)
事实证明可以被捕捉的
分享到:
相关推荐
java.lang.OutOfMemoryError: Java heap space 解决方法
ant编译时抛出OutOfMemoryError.doc
遭遇OutOfMemoryError 的解决方法。
java.lang.OutOfMemoryError,产生该错误的原因大都出于以下原因: JVM内存过小、程序不严密,产生了过多的垃圾.
java.lang.OutOfMemoryError处理错误
解决OutOfMemoryError: PermGen space,过程是痛苦的,结果是舒畅的
tomcat 出现 OutOfMemoryError 的解决方法
java.lang.OutOfMemoryError: PermGen space 解决方案
报错 java.lang.OutOfMemoryError: PermGen space 报错 java.lang.OutOfMemoryError: Java heap 启动报错java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler JAVA_OPTS="-server -Xms800m ...
Myeclipse下java.lang.OutOfMemoryError Java heap space的解决
搜集整理关于java错误处理:java.lang.OutOfMemoryError: Java heap space java.lang.OutOfMemoryError: Java heap space 资料整理
java.lang.OutOfMemoryError: PermGen space
OutOfMemoryError_8种典型案例分享,定位java内存问题
java.lang.OutOfMemoryError: Java heap space 解决方法
java解决nested exception is java.lang.OutOfMemoryError Java heap space 解决OOM
内存不足OOM java.lang.OutOfMemoryError.
java虚拟机OutOfMemoryError:Java heap space堆dump文件,可以直接用来分析。
Caused by: java.lang.OutOfMemoryError: PermGen space解决方案, avax.servlet.ServletException: java.lang.OutOfMemoryError: PermGen space at org.apache.jasper.servlet.JspServlet.service(JspServlet.java...
编译时出现java.lang.OutOfMemoryError Java heap space异常.