NutzCN Logo
问答 递归太深,导致内存溢出,有什么好的办法处理么
发布于 2664天前 作者 gitwqj 4793 次浏览 复制 上一个帖子 下一个帖子
标签:
org.nutz.dao.DaoException: org.nutz.lang.born.BorningException: Fail to born 'cn.xhbds.xhbs.lib.entity.DeviceMessage'
 by args: [
  @(com.alibaba.druid.pool.DruidPooledResultSet@1f760b47)] because:
java.lang.OutOfMemoryError: GC overhead limit exceeded
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248)
	at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
	at org.nutz.dao.impl.NutDao.execute(NutDao.java:973)
	at cn.xhbds.utils.TestTrackBack.addNewTrack(TestTrackBack.java:94)
	at cn.xhbds.utils.TestTrackBack.addNewTrack(TestTrackBack.java:158)
	at cn.xhbds.utils.TestTrackBack.addNewTrack(TestTrackBack.java:158)
        ........
	at cn.xhbds.utils.TestTrackBack.addNewTrack(TestTrackBack.java:158)
	at cn.xhbds.utils.TestTrackBack.addNewTrack(TestTrackBack.java:158)
	at cn.xhbds.utils.TestTrackBack.test(TestTrackBack.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:33)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.nutz.lang.born.BorningException: Fail to born 'cn.xhbds.xhbs.lib.entity.DeviceMessage'
 by args: [
  @(com.alibaba.druid.pool.DruidPooledResultSet@1f760b47)] because:
java.lang.OutOfMemoryError: GC overhead limit exceeded
	at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:19)
	at org.nutz.dao.impl.entity.NutEntity.getObject(NutEntity.java:226)
	at org.nutz.dao.impl.sql.callback.QueryEntityCallback$1.createObject(QueryEntityCallback.java:25)
	at org.nutz.dao.pager.ResultSetLooping.doLoop(ResultSetLooping.java:75)
	at org.nutz.dao.impl.sql.callback.QueryEntityCallback.process(QueryEntityCallback.java:29)
	at org.nutz.dao.impl.sql.callback.EntityCallback.invoke(EntityCallback.java:24)
	at org.nutz.dao.impl.sql.NutSql.onAfter(NutSql.java:135)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:277)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	... 125 more
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
	at java.util.HashMap.newNode(Unknown Source)
	at java.util.HashMap.putVal(Unknown Source)
	at java.util.HashMap.put(Unknown Source)
	at com.alibaba.fastjson.JSONObject.put(JSONObject.java:302)
	at com.alibaba.fastjson.JSONObject.put(JSONObject.java:51)
	at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:544)
	at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1312)
	at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1278)
	at com.alibaba.fastjson.JSON.parse(JSON.java:137)
	at com.alibaba.fastjson.JSON.parse(JSON.java:128)
	at com.alibaba.fastjson.JSON.parseObject(JSON.java:201)
	at cn.xhbds.xhbs.lib.entity.DeviceMessage.<init>(DeviceMessage.java:125)
	at sun.reflect.GeneratedConstructorAccessor17.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
	at org.nutz.dao.impl.entity.NutEntity.getObject(NutEntity.java:226)
	at org.nutz.dao.impl.sql.callback.QueryEntityCallback$1.createObject(QueryEntityCallback.java:25)
	at org.nutz.dao.pager.ResultSetLooping.doLoop(ResultSetLooping.java:75)
	at org.nutz.dao.impl.sql.callback.QueryEntityCallback.process(QueryEntityCallback.java:29)
	at org.nutz.dao.impl.sql.callback.EntityCallback.invoke(EntityCallback.java:24)
	at org.nutz.dao.impl.sql.NutSql.onAfter(NutSql.java:135)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:277)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
13 回复

试试 -XX:-UseGCOverheadLimit

加了,

-vmargs
-Dosgi.requiredJavaVersion=1.8
-XX:+UseG1GC
-XX:+UseStringDeduplication
-XX:-UseGCOverheadLimit
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-Declipse.p2.max.threads=10

这是eclipse的配置, 不会影响eclipse启动的Junit Test的

但是也没有解决这个问题,我可否在代码里面手动调用System.gc();呢

兽总的意思 你配置的属性位置不对

请问那应该在哪里配置呢,指点一下

运行的时候加在参数里边。

右键 Run As --> Run Configure ...

嗯嗯,好的

兽总,现在的问题是虽然没有报异常,但是内存还是没有回收,已经满了,然后数据库里面的数据就没有增加了

内存不会主动回收... 启动jconsole来观察吧

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