spring java.lang.OutOfMemoryError:带有 tomcat7 windows 服务的 PermGen 空间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13971380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 05:36:27  来源:igfitidea点击:

java.lang.OutOfMemoryError: PermGen space with tomcat7 windows service

springjakarta-eetomcattomcat7

提问by Mahmoud Saleh

i am running tomcat 7.0.33on windows server 2008 R2(i installed tomcat as windows service)

我在windows server 2008 R2上运行tomcat 7.0.33(我安装了 tomcat 作为 windows 服务)

  • JDK version:jdk1.6.0_25 64-bit
  • Tomcat options:

    1. Java Virtual Machine:C:\Program Files\Java\jre6\bin\server\jvm.dll(BTW, i don't have client folder inside jre)
    2. Initial memory pool:1000 MB
    3. Maximum memory pool:2000 MB

      when i check the server status, i can see that the server is using the memory i configured.

    4. Environment Variables (SYSTEM VARIABLES) Configuration:

      • JAVA_HOME:C:\Program Files\Java\jdk1.6.0_25
      • Path:...;%JAVA_HOME%\bin;....
  • JDK版本:jdk1.6.0_25 64-bit
  • Tomcat 选项:

    1. Java 虚拟机:(C:\Program Files\Java\jre6\bin\server\jvm.dll顺便说一句,我在 jre 中没有客户端文件夹)
    2. 初始内存池:1000 MB
    3. 最大内存池:2000 MB

      当我检查服务器状态时,我可以看到服务器正在使用我配置的内存。

    4. 环境变量(SYSTEM VARIABLES)配置:

      • JAVA_主页:C:\Program Files\Java\jdk1.6.0_25
      • 小路:...;%JAVA_HOME%\bin;....

do i need to add CATALINA_HOMEand JAVA_OPTSsystem variables too ?

我还需要添加CATALINA_HOMEJAVA_OPTS系统变量吗?

ISSUE:i have two web applications APP1,*APP2* when i deploy each one separately, i can find that memory use for

问题:我有两个 Web 应用程序APP1,* APP2* 当我分别部署每个应用程序时,我可以找到内存使用

APP1= 198 MB APP2= 104 MB

APP1= 198 MB APP2= 104 MB

Information about the applications:

有关应用程序的信息:

APP1,APP2: Spring Maven applications that includes in the libraries other small maven spring applications.

APP1,APP2: Spring Maven 应用程序,包括在库中的其他小型 Maven Spring 应用程序。

APP1: contains webservices, that APP2 uses them.

APP1:包含网络服务,APP2 使用它们。

if i tried to deploy both of them on same tomcat instance, i always get

如果我试图在同一个 tomcat 实例上部署它们,我总是得到

java.lang.OutOfMemoryError: PermGen space

please advise what might be causing this issue.

请告知可能导致此问题的原因。

回答by Mahmoud Saleh

the solution was beside setting initial & maximum memory pool, is to add -XX:MaxPermSize=1000mto the java options in the java tab.

除了设置初始和最大内存池之外,解决方案是添加-XX:MaxPermSize=1000m到 java 选项卡中的 java 选项。

回答by pap

You probably need to set/increase the MaxPermSize setting for your Tomcat instance. Note that the MAVEN_OPTS have nothing to do with Tomcat, those are options for the Maven command-line process (mvn). The fact that your application is a "maven" application means nothing at run-time as Maven is not involved in the runningof your application, only the buildingof it.

您可能需要为 Tomcat 实例设置/增加 MaxPermSize 设置。请注意,MAVEN_OPTS 与 Tomcat 无关,这些是 Maven 命令行进程 (mvn) 的选项。您的应用程序是“maven”应用程序这一事实在运行时没有任何意义,因为 Maven 不参与应用程序的运行,只参与它的构建

In the \binfolder in your tomcat installation, there should be an application called "tomcat7.exe". You can use this to update the settings for your tomcat service.

\bin您的 tomcat 安装文件夹中,应该有一个名为“tomcat7.exe”的应用程序。您可以使用它来更新 tomcat 服务的设置。

Try something like

尝试类似的东西

tomcat7.exe //US//[name of your tomcat service] --JvmOptions=-Xmx2g -Xms1g -XX:MaxPermSize=512m

tomcat7.exe //US//[您的tomcat服务名称] --JvmOptions=-Xmx2g -Xms1g -XX:MaxPermSize=512m

Edit: above statement should be on one line, not two...

编辑:上面的语句应该在一行上,而不是两行...

回答by Ondrej Burkert

I had a similar problem as our app run on Tomcat without problems when Tomcat run standalone and we kept getting permgen out of memory exceptions when running Tomcat as a service.

我有一个类似的问题,因为当 Tomcat 独立运行时,我们的应用程序在 Tomcat 上运行时没有问题,并且在将 Tomcat 作为服务运行时,我们不断收到 permgen out of memory 异常。

I found a solution simillar to the one of Pap. You need to access the Tomcat service configuration GUI by running bin/tomcat7w.exe //ES//name_of_service. There you go to the Java tab and set respective java properties directly - e.g. -XX:MaxPermSize=1000m

我找到了一个类似于 Pap 的解决方案。您需要通过运行 bin/tomcat7w.exe //ES//name_of_service 来访问 Tomcat 服务配置 GUI。在那里,您可以转到 Java 选项卡并直接设置相应的 Java 属性 - 例如 -XX:MaxPermSize=1000m

Here is a blog post which helped me a lot explaining what all Tomcat settings are ignored by Tomcat when running as a service. http://www.12robots.com/index.cfm/2010/10/8/Giving-more-memory-to-the-Tomcat-Service-in-Windows

这是一篇博客文章,它帮助我解释了 Tomcat 在作为服务运行时忽略的所有 Tomcat 设置。 http://www.12robots.com/index.cfm/2010/10/8/Giving-more-memory-to-the-Tomcat-Service-in-Windows

回答by mindas

You need to increase PermGen space. Add something like -XX:MaxPermSize=128mto your parameters (you can reserve more perm gen space if you want to). The -Xmxand -Xmssettings are for heap whereas here you're running out of PermGen spacewhich is administered separately.

您需要增加永久代空间。-XX:MaxPermSize=128m在您的参数中添加类似的内容(如果您愿意,您可以保留更多的烫发空间)。在-Xmx-Xms设置对于堆,而在这里你的耗尽PermGen的空间,这是分开管理。