JVM内存不足,怎么办啊,生产环境出问题了

[code="java"]HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
cn.csdb.palpp.util.EncodingFilter.doFilter(EncodingFilter.java:39)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
root cause

java.lang.OutOfMemoryError: Java heap space
java.lang.StringCoding$StringDecoder.decode(StringCoding.java:133)
java.lang.StringCoding.decode(StringCoding.java:173)
java.lang.String.(String.java:443)
java.lang.String.(String.java:515)
org.apache.commons.fileupload.disk.DiskFileItem.getString(DiskFileItem.java:385)
cn.csdb.palpp.util.FileUtil.doUploadFileFromRequest(FileUtil.java:210)
cn.csdb.palpp.web.AdminController.doFileUpload(AdminController.java:751)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:472)
org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:409)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
cn.csdb.palpp.util.EncodingFilter.doFilter(EncodingFilter.java:39)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.

Apache Tomcat/5.5.27[/code]

6个回答

org.apache.commons.fileupload.disk.DiskFileItem.getString(DiskFileItem.java:385)

cn.csdb.palpp.util.FileUtil.doUploadFileFromRequest(FileUtil.java:210)

cn.csdb.palpp.web.AdminController.doFileUpload(AdminController.java:751)

是因为你传的文件太大,才OOMl了吧,2个操作:
1.调大你的堆
http://blog.sina.com.cn/s/blog_594058420100efss.html
这里面的Xmsn、Xmxn两个参数

2.限制上传文件的大小,不管你的堆调整的多大,这都是要限制的,不然他传个1G的文件,也能搞死你,一般限制成50M左右也差不多了,特别大的文件,搞个FTP上传吧,没必要一定要在网页上搞个功能折腾自己

百度下这个:
java.lang.OutOfMemoryError: Java heap space

答案一大把,你可以试试!

内存溢出就是内存不足,为什么内存不足,首先可能是你的JDK本身设置的就不足,你可以百度搜一下,设置JDK内存的方法,很多的。另外一个原因就是垃圾没有及时回收,垃圾回收器没有回收垃圾,如果你是对系统要求比较高的话可以网上找一些垃圾回收器用到你的项目里面,另外对你的代码做优化,比如A a = new A();如果你这个a不用了,那就让a=null;这样的话垃圾回收器检查到没有引用到new出来的A实例时就回收了,腾出内存来,如果用到Hibernate的话对一对多的多的一端延迟加载策略。应该还有其他的方式来解决你这个问题,你可以百度找找,这些是我个人的见解,希望对你有帮助。

你是在执行什么操作时,出现这问题的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问