部署 tomcat 7 时出现 PermGen Space 错误?

2022-09-02 11:26:58

我安装了tomcat 7,将我的JIRA projeect版本从5.0升级到6。在我把项目文件夹放在tomcat的web应用程序中之后。我在长时间运行后运行此本地主机:8080 / jira,它抛出一些错误消息。请帮助我们解决这个问题,谢谢提前

java.lang.RuntimeException: PermGen space
    at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54)
    at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66)
    at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32)
    at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60)
    at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160)
    at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79)
    at com.atlassian.plugin.event.impl.DefaultPluginEventManager.broadcast(DefaultPluginEventManager.java:84)
    at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:768)
    at com.atlassian.plugin.manager.DefaultPluginManager.init(DefaultPluginManager.java:200)
    at com.atlassian.jira.plugin.JiraPluginManager.start(JiraPluginManager.java:63)
    at com.atlassian.jira.ComponentManager$PluginSystem.start(ComponentManager.java:635)
    at com.atlassian.jira.ComponentManager.startJIRA(ComponentManager.java:214)
    at com.atlassian.jira.ComponentManager.quickStart(ComponentManager.java:208)
    at com.atlassian.jira.ComponentManager.start(ComponentManager.java:193)
    at com.atlassian.jira.upgrade.PluginSystemLauncher.start(PluginSystemLauncher.java:23)
    at com.atlassian.jira.startup.DefaultJiraLauncher$3.run(DefaultJiraLauncher.java:107)
    at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrEnqueue(DatabaseConfigurationManagerImpl.java:323)
    at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrWhenDatabaseActivated(DatabaseConfigurationManagerImpl.java:211)
    at com.atlassian.jira.startup.DefaultJiraLauncher.postDbLaunch(DefaultJiraLauncher.java:100)
    at com.atlassian.jira.startup.DefaultJiraLauncher.access$100(DefaultJiraLauncher.java:27)
    at com.atlassian.jira.startup.DefaultJiraLauncher$1.run(DefaultJiraLauncher.java:66)
    at com.atlassian.jira.util.devspeed.JiraDevSpeedTimer.run(JiraDevSpeedTimer.java:33)
    at com.atlassian.jira.startup.DefaultJiraLauncher.start(DefaultJiraLauncher.java:61)
    at com.atlassian.jira.startup.LauncherContextListener.contextInitialized(LauncherContextListener.java:54)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: PermGen space

答案 1

更有用的解决方案是增加变量JAVA_OPTS值。
将下一行添加到目录中的文件Catalina.bat/Catalina.shbin

For Windows (Catalina.bat)

set JAVA_OPTS="-Xms1024m -Xmx10246m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m"  

对于 Unix (Catalina.sh)

export JAVA_OPTS="-Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m"  

您可以在本文中找到更多解决方案


答案 2

有时,在重新部署后,垃圾回收器无法破坏Tomcat上的某些对象并耗尽空间。造成这些情况的原因有很多:

  • 如果您使用某些CRUD对象 - 检查使用后是否全部关闭。
  • 如果你的应用程序使用了其他库 - 有时这些库中的对象也无法被销毁,如MysqlConnector,Hibernate / C3p0或其他 - 请尝试将这些库放在tomcat / lib文件夹中

使用“Java VisualVM”检查Tomcat,并在重新部署后检查permGen。
permGen 空间的默认值通常也非常低,您可以使用以下 javaVM 参数增加它们

 -XX:PermSize=64M -XX:MaxPermSize=256m

您可以按照这些教程进行操作

http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/

更新

也许在这里找到的其他解决方案:如何处理tomcat PermGen空间

将 -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC 添加到 javaVM 选项


推荐