62,614
社区成员
发帖
与我相关
我的任务
分享
/**
@author hlayy
@version 0.1
*/
import java.util.*;
public class MemoryNotEnough
{
public static void main(String [] args)
{
String str = new String("str");
String str2 = new String("Str2");
String str3 = new String("Str3");
try
{
for(int i = 0 ; i<100000;i++)
{
str = str + str2;
str2 = str2 + str;
str3 = str3 + str2;
}
}
catch(OutOfMemoryError o)
{
System.out.println("内存泄漏错误!");
}
}
}
try{
...
}catch(Throwable e){
...处理异常
System.exit(-1);
}