iteye_2644
iteye_2644
2011-09-27 14:51
浏览 498
已采纳

tomcat6 启动加载项目时报内存溢出 急

[color=red]在windows系统下。
我将一个大的项目拷贝到tomcat/webapps该目录下,在启动tomcat时报内存溢出,也试过在bin/catalina目录下添加set JAVA_OPTS此内容,启动后结果还是一样报错,敬请帮忙 [size=xx-small][/size][/color]

以下是部分报错信息:

  • Closing Hibernate SessionFactory
  • closing
  • Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'velocityEngine' defined in class path resource [conf/app-resou rces.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at com.htsoft.core.web.listener.StartupListener.contextInitialized(StartupListener.java:22) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at org.apache.velocity.runtime.RuntimeInstance.getString(RuntimeInstance.java:1656) at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:625) at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:251) at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:107) at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:256) at org.springframework.ui.velocity.VelocityEngineFactoryBean.afterPropertiesSet(VelocityEngineFactoryBean.java:57) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369 ) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at com.htsoft.core.web.listener.StartupListener.contextInitialized(StartupListener.java:22) 2011-9-27 14:39:51 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class com.htsoft.core.web.listener.StartupListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'velocityEngine' defined in class path resource [conf/app-resou rces.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

21条回答 默认 最新

  • chenjingbo009
    chenjingbo009 2011-09-27 17:52
    已采纳

    那你别把工程copy到webapps下啊.其他任何地方都可以..然后在 指过去,就可以了..

    点赞 评论
  • DreamZhong
    DreamZhong 2011-09-27 14:57

    重新打包一下项目 rebuild

    点赞 评论
  • iteye_12540
    iteye_12540 2011-09-27 15:17

    调整服务器启动时的内存分配。缺省服务器的内存容量,各个区的容量一般偏小,请根据自己的情况进行调整。

    点赞 评论
  • liuwei890624
    磊子_济南 2011-09-27 16:10

    双击..\bin\tomcat5w.exe打开,点击java按钮,修改Inital memory pool和Maximum memory pool的大小。
    如果还不行就配置系统环境变量:
    变量名:JAVA_OPTS
    变量值:-Xms64m -Xmx512m
    根据自己的机器调整变量值的大小。

    点赞 评论
  • iteye_12540
    iteye_12540 2011-09-27 16:10

    JAVA_OPTS没有设置对。你仔细看一下。

    点赞 评论
  • liuwei890624
    磊子_济南 2011-09-27 16:30

    问题补充:

    魔力猫咪 写道
    JAVA_OPTS没有设置对。你仔细看一下。

    我是将下面的内容设置在bin/cataline.bat文件中的
    set JAVA_OPTS=-Xms800m -Xmx800m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m

    这种方式我曾经试过,但是不知道为什么不好用,你最好试试设置系统环境变量。

    点赞 评论
  • liuwei890624
    磊子_济南 2011-09-27 16:33

    我用的是TOMCAT5.0,你看看有没有..\bin\tomcat6w.exe或者类似的文件。

    点赞 评论
  • qq1988627
    qq1988627 2011-09-27 16:38

    配置下jvm大小

    点赞 评论
  • liuwei890624
    磊子_济南 2011-09-27 16:41

    那就只能通过修改配置文件了。

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 16:46

    Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space
    已经很明确的告诉你 PermGen溢出了..你只要增加permGen大小就可以了..具体的配置就是
    -XX:MaxPermSize=512m
    如果你的工程连512m都不够,那么我觉得可能是死循环造成的..因为整个eclipse也就一百多m..

    点赞 评论
  • qq1988627
    qq1988627 2011-09-27 16:47

    configure server ->server->tomcat->jdk->java VM下面方框里数据配置信息

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 16:48

    我很好奇,你竟然连256m都不够..你可以开visualVM看看..具体的PermGen占了多少

    点赞 评论
  • liuwei890624
    磊子_济南 2011-09-27 16:53

    就是你改过的bin/cataline.bat文件中的
    set JAVA_OPTS=-Xms800m -Xmx800m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m
    修改后在管理,服务里面重新启动下
    如果还不好用,建议换个其他版本的服务器

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 16:55

    如果你是用eclipse跑的话,参考上面那位仁兄的位置,加上 -XX:MaxPermSize=512m 试试看.
    你打开visualVM看看,这个配置是否生效了.visualVM就在jdk的bin目录..JVisualVM .

    点赞 评论
  • DreamZhong
    DreamZhong 2011-09-27 16:56

    -Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m
    我是这样在服务器配置中进行设置的。

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 16:59

    [quote]就是你改过的bin/cataline.bat文件中的
    set JAVA_OPTS=-Xms800m -Xmx800m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m
    修改后在管理,服务里面重新启动下
    如果还不好用,建议换个其他版本的服务器
    [/quote]
    上面这个方法是对的..至于这个修改是否生效,再说一次,打开visualVM看看

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 17:01

    @Wind_ZhongGang 你们这个服务器配置,我的建议是 -Xms512m -Xmx1024m 这两个值设置成一样,否则在堆扩容或者降容的时候都会造成额外的full gc.而这个是完全可以避免的..

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 17:22

    你把工程放到tomcat下,他需要加载这么多class类信息等等,所以造成的永久代溢出的..你不加载工程当然就不会有溢出.你能看到对应永久代的大小不..用visualVM

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 17:36



    这句就是指向工程目录的,怎么会没加载哦.呵呵

    点赞 评论
  • chenjingbo009
    chenjingbo009 2011-09-27 17:41

    晕,你在webapp下放着,又在server.xml里配置..会造成重复的..这个重复会不会出问题..我没试过..你可以试试把server.xml里的工程加载配置删除,直接启动,然后访问

    点赞 评论
  • lijieshare
    lijieshare 2011-09-27 18:10
    点赞 评论

相关推荐