求教这是内存溢出的BUG吗?

线上项目,运行中不知道什么时候就会突然服务终止。异常如下:

2017-04-30 01:37:31
[ERROR]-[Thread: ajp-apr-10462-exec-9]-[com.jfinal.core.ActionHandler.handle()]: /page/chapter

2017-04-30 01:38:06
[ERROR]-[Thread: ajp-apr-10462-exec-11]-[com.jfinal.core.ActionHandler.handle()]: /page/chapter
java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space
	at com.jfinal.aop.Invocation.invoke(Invocation.java:93)
	at com.jfinal.plugin.activerecord.tx.Tx.intercept(Tx.java:77)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.aop.Callback.intercept(Callback.java:96)
	at model.BuyRecord$$EnhancerByCGLIB$$df9f0948.saveAuto(<generated>)
	at model.Chapter.needPay(Chapter.java:207)
	at controller.MobilePageController.chapter(MobilePageController.java:32)
	at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82)
	at Xss.XssHandler.handle(XssHandler.java:22)
	at config.GlobalHandler.handle(GlobalHandler.java:51)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:74)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
	at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:188)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2462)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2451)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.OutOfMemoryError: Java heap space

2017-04-30 01:37:50
[ERROR]-[Thread: chapter%004eovel.data]-[net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call()]: Disk Write of 177025d068 failed: 
java.lang.OutOfMemoryError: Java heap space

2017-04-30 01:37:46
[ERROR]-[Thread: view%0055ser.data]-[net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call()]: Disk Write of 1d3d22f9554047568121c63e2ea2c3f42017-04-30 failed: 
java.lang.OutOfMemoryError: Java heap space

2017-04-30 01:39:07
[ERROR]-[Thread: history.data]-[net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call()]: Disk Write of 3ac962bae6d64fe28ce8f2907dace457e3df0720 failed: 
java.lang.OutOfMemoryError: Java heap space

2017-04-30 01:39:21
[ERROR]-[Thread: history.data]-[net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call()]: Disk Write of 092b8c9b4324453eaeab7f823e818efc486aea9d failed: 
java.lang.OutOfMemoryError: Java heap space

2017-04-30 01:39:35
[ERROR]-[Thread: chapter%004eovel.data]-[net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call()]: Disk Write of 1087eeaca6 failed: 
java.lang.OutOfMemoryError: Java heap space


这是程序的问题吗?请问该从哪里入手处理?

评论区

要输就输给追求

2017-04-30 22:23

看看你这里面都干啥了啊 page/chapter

nbjgl

2017-05-02 09:11

跟这里没关系吧

nbjgl

2017-05-02 09:15

JFinal

2017-05-02 09:56

OutOfMemoryError 主要分两种情况:
1:自己的程序写得有 bug,有内存泄漏的代码存在
2:没有内存泄漏的代码存在,但内存被消耗的速度大于内存回收的速度,常常是由于程序在某些地方高速 new 出大对象,内存回收来不及

最快的解决方案是利用 jprofile 这类专业性的工具:http://www.oschina.net/p/jprofiler

当然,你如果嫌这类工具比较麻烦,也可以用一下 jdk 自带的 jmap、jstack、jstat这类工具辅助解决,这些工具的具体用法网上多得是

热门反馈

扫码入社