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

29,660

Solution 1

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

Solution 2

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 running of your application, only the building of it.

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

Try something like

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

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

Solution 3

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.

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

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

Solution 4

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

Share:
29,660
Mahmoud Saleh
Author by

Mahmoud Saleh

I am Mahmoud Saleh an Enthusiastic Software Engineer, Computer Science Graduate, Experienced in developing J2EE applications, Currently developing with Spring,JSF,Primefaces,Hibernate,Filenet. Email: [email protected] Linkedin: https://www.linkedin.com/in/mahmoud-saleh-60465545? Upwork: http://www.upwork.com/o/profiles/users/_~012a6a88e04dd2c1ed/

Updated on July 23, 2020

Comments

  • Mahmoud Saleh
    Mahmoud Saleh almost 4 years

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

    • 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;....

    do i need to add CATALINA_HOME and JAVA_OPTS system variables too ?

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

    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: contains webservices, that APP2 uses them.

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

    java.lang.OutOfMemoryError: PermGen space
    

    please advise what might be causing this issue.