Java堆溢出: java.lang.OutOfMemoryError: Java heap space
- /**
- * VM Args:-Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError
- * @author zzm
- */
- ublic class HeapOOM {
- static class OOMObject {
- }
- public static void main(String[] args) {
- List<OOMObject> list = new ArrayList<OOMObject>();
- while (true) {
- list.add(new OOMObject());
- }
- }
- }
运行结果:
- java.lang.OutOfMemoryError: Java heap space
- Dumping heap to java_pid3404.hprof ...
- Heap dump file created [22045981 bytes in 0.663 secs]
http://book.51cto.com/art/201107/278889.htm
虚拟机栈和本地方法栈溢出
(java.lang.StackOverflowError)
- stack length:2402
- Exception in thread "main" java.lang.StackOverflowError
http://book.51cto.com/art/201107/278890.htm
运行时常量池溢出
(OutOfMemoryError: PermGen space at org.fenixsoft.oom.RuntimeConstantPoolOOM)
- Exception in thread "main" java.lang.
- [b]OutOfMemoryError: PermGen space[/b]
- at java.lang.String.intern(Native Method)
- at org.fenixsoft.oom.[b]RuntimeConstantPoolOOM[/b].
- main(RuntimeConstantPoolOOM.java:18)
http://book.51cto.com/art/201107/278891.htm
方法区溢出
(Caused by: java.lang.OutOfMemoryError: PermGen space )
- Caused by: [b]java.lang.OutOfMemoryError: PermGen space [/b]
- at java.lang.ClassLoader.defineClass1(Native Method)
- at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
- at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
- ... 8 more
在经常动态生成大量Class的应用中,需要特别注意类的回收状况。这类场景除了上面提到的程序使用了GCLib字节码增强外,常见的还有:大量JSP或动态产生JSP文件的应用(JSP第一次运行时需要编译为Java类)、基于OSGi的应用(即使是同一个类文件,被不同的加载器加载也会视为不同的类)等。
http://book.51cto.com/art/201107/278894.htm
本机直接内存溢出
(Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory)
public class Test {
public static void main(String[] args) {
for (int i = 0; i < 10000; i++) {
createThread();
System.out.println(i);
}
}
private static void createThread() {
ByteBuffer bf = ByteBuffer.allocateDirect(1024 *1024 *100);
}
}
gc 日志:2017-05-14T20:02:37.074+0800: [GC [PSYoungGen: 717K->568K(5952K)] 717K->568K(19648K), 0.0060602 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 2017-05-14T20:02:37.081+0800: [Full GC (System) [PSYoungGen: 568K->0K(5952K)] [ParOldGen: 0K->485K(13696K)] 568K->485K(19648K) [PSPermGen: 2527K->2525K(21248K)], 0.0097560 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory at java.nio.Bits.reserveMemory(Bits.java:658) at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306) at Test.createThread(Test.java:22) at Test.main(Test.java:7)
注意: 对于 DirectByteBuffer 因为不是在虚拟机分配的,full gc 日志 体现不了 日志回收的情况
这样分配的内存不再是在java heap上,而是在C heap上
相关推荐
java.lang.OutOfMemoryError,产生该错误的原因大都出于以下原因: JVM内存过小、程序不严密,产生了过多的垃圾.
tomcat内存溢出解决办法,错误信息:java.lang.OutOfMemoryError:PermGen space 参考该文档可快速解决内存溢出的问题,服务器:tomcat
Java内存分析工具MAT(Memory Analyzer Tool) 可以解析内存的消耗,定位具体的类,定位问题
Java中OutOfMemoryError(内存溢出)的三种情况及解决办法
java.lang.OutOfMemoryError: PermGen space及其解决方法,解决项目太大tomcat内存溢出
maven构建时发生内存溢出的有很多种情况,比如eclipse-plugin,maven命令时,这里总结了分别怎么解决。
Tomcat内存溢出的解决方法(java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError),内附解决方案!
poi读取大量数据会造成gc内存溢出的报错,由于垃圾回收机制无法将大量的对象及时的回收,而这些对象又会保存在内存中,会导致内存不够用的情况,这时候我们就需要使用新的方法,读取为cvs即可.此解决方案可支持千万数据的...
JVM PermGen space 溢出 JVM heap space 溢出 Native Heap 溢出 三种溢出原因 供大家参考
解压缩开源软件junrar中存在bug,使用中会出现java.lang.OutOfMemoryError的错误,本资源包含了解决方法和修改后的junrar代码。
Java内存溢出解决办法 加大Tomcat使用Jvm内存(转载) 注重版权 Caused by: java lang OutOfMemoryError: Java heap space 错误原因及解决方法
java.lang.OutOfMemoryError: PermGen space,OutOfMemoryError是内存溢出1、weblogic域的bin目录
tomcat内存溢出总结 在生产环境中tomcat内存设置不好很容易出现内存溢出。造成内存原因是不一样的,当然处理方式也不一样。 这里根据平时遇到的情况和相关资料进行一个总结。常见的一般会有下面三种情况: 1....
ermGen space的全称是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存益出,解决方法也一定是加大内存。说说为什么会内存益出:这一部分 用于存放Class和...
关于Java中内存溢出的解决办法 关于Java中内存溢出的解决办法
TOMCAT出错:java.lang.OutOfMemoryError: Java heap space
下面小编就为大家带来一篇完美解决java读取大文件内存溢出的问题。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Tomcat内存溢出的三种情况及解决办法分析 Tomcat内存溢出的原因 在生产环境中tomcat内存设置不好很容易出现内存溢出。造成内存原因是不一样的,当然处理方式也不一样。 这里根据平时遇到的情况和相关资料进行一个...
- 第2章 Java内存区域与内存溢出异常- 2.4 实战:OutOfMemoryError异常2.4.4 本机直接内存溢出直接内存(Direct Memory
java 内存 溢出 通用办法