NutzCN Logo
问答 nutzcn爆内存溢出错误, java.lang.OutOfMemoryError
发布于 2996天前 作者 wendal 2455 次浏览 复制 上一个帖子 下一个帖子
标签:

下载heap dump中, 等待分析

20:09:48.743 WARN  (FailProcessor.java:28) process - Error@/yvr/list :
java.lang.OutOfMemoryError: Java heap space
        at sun.misc.Unsafe.defineClass(Native Method) ~[?:1.8.0_102]
        at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63) ~[?:1.8.0_102]
        at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399) ~[?:1.8.0_102]
        at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:394) ~[?:1.8.0_102]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_102]
        at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:393) ~[?:1.8.0_102]
        at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:112) ~[?:1.8.0_102]
        at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:340) ~[?:1.8.0_102]
        at java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1420) ~[?:1.8.0_102]
        at java.io.ObjectStreamClass.access$1500(ObjectStreamClass.java:72) ~[?:1.8.0_102]
        at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:497) ~[?:1.8.0_102]
        at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:472) ~[?:1.8.0_102]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_102]
        at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:472) ~[?:1.8.0_102]
        at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:369) ~[?:1.8.0_102]
        at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:598) ~[?:1.8.0_102]
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1630) ~[?:1.8.0_102]
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521) ~[?:1.8.0_102]
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1630) ~[?:1.8.0_102]
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521) ~[?:1.8.0_102]
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781) ~[?:1.8.0_102]
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353) ~[?:1.8.0_102]
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373) ~[?:1.8.0_102]
        at org.nutz.plugins.cache.dao.impl.convert.JavaCacheSerializer.back(JavaCacheSerializer.java:41) ~[nutz-plugins-daocache-1.r.56.jar:?]
        at org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider.get(EhcacheDaoCacheProvider.java:24) ~[nutz-plugins-daocache-1.r.56.jar:?]
        at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:137) ~[nutz-plugins-daocache-1.r.56.jar:?]
        at net.wendal.nutzbook.util.MasterSlaveDaoExecutor.exec(MasterSlaveDaoExecutor.java:39) ~[classes/:?]
        at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66) ~[nutz-1.r.58-SNAPSHOT.jar:?]
        at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22) ~[nutz-1.r.58-SNAPSHOT.jar:?]
        at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64) ~[nutz-1.r.58-SNAPSHOT.jar:?]
        at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139) ~[nutz-1.r.58-SNAPSHOT.jar:?]
        at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:147) ~[nutz-1.r.58-SNAPSHOT.jar:?]
5 回复

趁下载heap文件的间隙, 下载神器mat

http://www.eclipse.org/mat/downloads.php

@wendal 直播一下 调试过程,,让我们看看大神是怎么炼成的。。哈哈

一般人不敢回这个帖子,围观路过..

原因如下:

第一, dubbo很多类都创建了线程池,但没有关闭操作,导致线程泄漏,强引用WebClassLoader,导致无法释放

第二, dubbo的AbstractConfig中有一个静态代码库,注册了ShutdownHook, 又是强引用.

第三, log4j v2 自动注册了jmx的mbean, 强引用WebClassLoader,导致无法释放

第四, log4j 也注册了一个ShutdownHook,坑啊

解决办法:

第一和第二, 移除dubbo及其插件!!! 坑了一个晚上,各种线程池和静态块, 还有jmx, 啊啊啊啊!!!

第三, 启动参数加上下面的配置,禁用它

-Dlog4j2.disable.jmx=true

第四, 加上依赖库 log4j-web 后自动禁用.

参考文档:

第一, 直接给源码 https://github.com/alibaba/dubbo/blob/405003ac67d3530cc7318e2c64cd97edf4d36660/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java 看447h行

第二, 给出2个类做例子, MulticastRegistry和FailbackRegistry, 里面的线程池只创建,不关闭!!

第三, 给出官网文档链接 http://logging.apache.org/log4j/2.x/manual/jmx.html

第四, 也是官网链接 http://logging.apache.org/log4j/2.x/manual/webapp.html

添加回复
请先登陆
回到顶部