MyEclipse使用Tomcat,报OutOfMemoryError的解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/geyouchao/article/details/51546501
首先弄清楚是怎么报此内存溢出的问题,出现此问题首先排除程序中是否有错误代码导致的。若以前都运行正常的,由于加入一些功能或修改功能后就突然报此错误,那么我们就应该怀疑是否是我们的环境出问题?


确定是怎么操作报的内存溢出问题:


1. 若是单独启动Tomcat(运行startup.bat)报错,可以这样修改catalina.bat文件(假设在Windows中):


在“rem ----- Execute The Requested Command ---------------------------------------”这一行之后,“echo Using CATALINA_BASE: “%CATALINA_BASE%” ”这一行之前,加入:


set JAVA_OPTS=%JAVA_OPTS% -server -XX:PermSize=512m -XX:MaxPermSize=512m
再次启动tomcat,ok;


2. 若是在MyEclipse中,需要修改下图所示的界面中jvm的参数设置:



在 Optional Java VM arguments中设置:


-Xms512m -Xmx512m -XX:PermSize=512m -XX:MaxPermSize=512m


 


好了,可以启动tomcat了

Tomcat已经加大内存,但还是报OutOfMemoryError: PermGen space

06-27

2014-06-27 10:25:20,252 INFO - Starting: DwrServlet v3.0.0-RC2-final-312 on Apache Tomcat/6.0.39 / JDK 1.6.0_13 from Sun Microsystems Inc. at /oarn2014-06-27 10:25:23,704 ERROR - 构建kj-table失败rnjavax.servlet.jsp.JspException: java.lang.OutOfMemoryError: PermGen spacern at org.apache.jsp.user.userlist_jsp$Helper.invoke(userlist_jsp.java:927)rn at kjoms.webframework.webform.widget.table.TableWidget.doTag(TableWidget.java:216)rn at org.apache.jsp.user.userlist_jsp._jspx_meth_KjWebWidget_005fTable_005f0(userlist_jsp.java:576)rn at org.apache.jsp.user.userlist_jsp._jspService(userlist_jsp.java:530)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:428)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at kjoms.oa.publics.LoginFilter.doFilter(LoginFilter.java:71)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at kjoms.oa.publics.SetEncodingFilter.doFilter(SetEncodingFilter.java:28)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:619)rnCaused by: java.lang.OutOfMemoryError: PermGen spacern at sun.misc.Unsafe.defineClass(Native Method)rn at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)rn at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)rn at java.security.AccessController.doPrivileged(Native Method)rn at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)rn at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:76)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at java.lang.Class.newInstance0(Class.java:355)rn at java.lang.Class.newInstance(Class.java:308)rn at org.apache.velocity.util.ClassUtils.getNewInstance(ClassUtils.java:95)rn at org.apache.velocity.runtime.RuntimeInstance.loadDirective(RuntimeInstance.java:836)rn at org.apache.velocity.runtime.RuntimeInstance.initializeDirectives(RuntimeInstance.java:806)rn at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:242)rn at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:534)rn at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:144)rn at kjoms.webframework.webform.widget.WebWidgetService.buildWidgetHTML(WebWidgetService.java:139)rn at kjoms.webframework.webform.widget.BaseWidget.doTag(BaseWidget.java:96)rn at org.apache.jsp.user.userlist_jsp._jspx_meth_KjWebWidget_005fColumn_005f5(userlist_jsp.java:698)rn at org.apache.jsp.user.userlist_jsp.access$5(userlist_jsp.java:683)rn at org.apache.jsp.user.userlist_jsp$Helper.invoke0(userlist_jsp.java:863)rn at org.apache.jsp.user.userlist_jsp$Helper.invoke(userlist_jsp.java:917)rn at kjoms.webframework.webform.widget.table.TableWidget.doTag(TableWidget.java:216)rn at org.apache.jsp.user.userlist_jsp._jspx_meth_KjWebWidget_005fTable_005f0(userlist_jsp.java:576)rn at org.apache.jsp.user.userlist_jsp._jspService(userlist_jsp.java:530)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)rn2014-6-27 10:25:23 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet jsp threw exceptionrnjava.lang.OutOfMemoryError: PermGen spacern at sun.misc.Unsafe.defineClass(Native Method)rn at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)rn at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)rn at java.security.AccessController.doPrivileged(Native Method)rn at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)rn at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:76)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at java.lang.Class.newInstance0(Class.java:355)rn at java.lang.Class.newInstance(Class.java:308)rn at org.apache.velocity.util.ClassUtils.getNewInstance(ClassUtils.java:95)rn at org.apache.velocity.runtime.RuntimeInstance.loadDirective(RuntimeInstance.java:836)rn at org.apache.velocity.runtime.RuntimeInstance.initializeDirectives(RuntimeInstance.java:806)rn at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:242)rn at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:534)rn at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:144)rn at kjoms.webframework.webform.widget.WebWidgetService.buildWidgetHTML(WebWidgetService.java:139)rn at kjoms.webframework.webform.widget.BaseWidget.doTag(BaseWidget.java:96)rn at org.apache.jsp.user.userlist_jsp._jspx_meth_KjWebWidget_005fColumn_005f5(userlist_jsp.java:698)rn at org.apache.jsp.user.userlist_jsp.access$5(userlist_jsp.java:683)rn at org.apache.jsp.user.userlist_jsp$Helper.invoke0(userlist_jsp.java:863)rn at org.apache.jsp.user.userlist_jsp$Helper.invoke(userlist_jsp.java:917)rn at kjoms.webframework.webform.widget.table.TableWidget.doTag(TableWidget.java:216)rn at org.apache.jsp.user.userlist_jsp._jspx_meth_KjWebWidget_005fTable_005f0(userlist_jsp.java:576)rn at org.apache.jsp.user.userlist_jsp._jspService(userlist_jsp.java:530)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)rn2014-6-27 10:25:24 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet jsp threw exceptionrnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试