2

I know there are many SO questions and answers on this issue; I have tried 8 or 10 different things that worked for other people, and feel in need of analysis of what's wrong rather than trial and error.

I am running on a Windows 64 bit machine, Spring Tool Suite 3.1, Jetty internal server. I am running one web application; its initial screen appears, I click on a link that performs an operation, it processes for perhaps 10 seconds, and then gives me the following

HTTP ERROR 500
Problem accessing /corrserv/printRoom/printManagement.html;jsessionid=uroykwoyxr2y.     
Reason: 

PermGen space

Caused by:
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at org.eclipse.jdt.internal.compiler.Compiler.<init>(Compiler.java:109)
at org.apache.jasper.compiler.JDTJavaCompiler.compile(JDTJavaCompiler.java:498)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:368)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)
at org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:261)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:683)
at org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:88)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:739)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1501)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2291)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2341)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2347)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:498)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2291)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFiles(TagFileProcessor.java:757)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:222)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:435)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)


--------------------------------------------------------------------------------
Powered by Jetty://

The following is my STS.ini file:

-vm
C:/Program Files (x86)/Java/jdk1.6.0_43/bin/javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120522-1813
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512m
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms256m
-Xmx512m
-XX:MaxPermSize=512m

I have tried many things for the last three values. I have put in 123456789m to ensure that STS reads this particular file (it won't start with that value). I am only running one web application. I used to have -XX:PermSize as well, will be happy to try that again. It is unfortunate that I don't know how these interact; only their basic meanings.

I would appreciate some guidance on how to solve this, or at least how to attack it.

Charles
  • 50,943
  • 13
  • 104
  • 142
arcy
  • 12,845
  • 12
  • 58
  • 103
  • 1
    I know the solution of "throw more memory at it" isn't always ideal, but you still get this error when increasing your `MaxPermSize` to 1024m? – Default Mar 19 '13 at 20:31
  • yes I do. don't know if I should have changed any others when I changed that one, but I've used that number in various combinations. – arcy Mar 19 '13 at 20:32
  • 4
    Have you tried [memory profiling](http://stackoverflow.com/questions/3728713/what-java-memory-profiler-applications-will-work-on-windows-7-64-bit-with-java-1) to figure out what is filling up memory? You might just have runaway code creating infinite objects.... – Russell Zahniser Mar 19 '13 at 20:33
  • 2
    So what happens if you increase -Xmx to, say, 2048m? Remember, using a lot of "PermGen" usually means you're instantiating a lot of class objects. See my notes below. – paulsm4 Mar 19 '13 at 20:47
  • 1
    I am afraid, that STS.ini file only configures STS jvm itself. And Jetty is run in separate JVM with default settings. You should look into Run configuration for an option to change Jetty JVM startup parameters – Nikem Mar 20 '13 at 10:27
  • @rcook - you've got lots of good suggestions - please let us know how things go. See also this link: [Dealing with Java lang OutOfMemoryError Permgen Space](http://stackoverflow.com/questions/88235/dealing-with-java-lang-outofmemoryerror-permgen-space-error/11452196#11452196) – paulsm4 Mar 20 '13 at 15:25

4 Answers4

4

This is can be resolved by looking at the version (bit version) of JDK. like a 32-bit application using a 64-bit JDK version. Change to the correct JDK version and the correct JRE.

  • 1
    This turned out to be the problem; my colleague and I worked on it, using a number of the excellent suggestions provided by other answers and comments. I really appreciate the suggestions for how to hunt it down, many of them helped. – arcy Mar 23 '13 at 09:53
2

The problem appears to be in the jsp itself. I would guess it is filling up PermGen with classes. Can you post the jsp code?

Adding memory isn't the fix to this. There is something filling it and you need to find that something.

Jerry Hoerig
  • 146
  • 9
  • 1
    The trace shows it's blowing up while executing the compilation of the JSP. Profiling is overkill. Look at the JSP and look for cylces, loops, etc. – Jerry Hoerig Mar 19 '13 at 20:42
  • 1
    Taking a second look at things with a tool like JVisualVM is *never* a waste of time. IMHO. And I'm not sure "the JSP" is necessarily the culprit. – paulsm4 Mar 19 '13 at 21:37
  • 1
    I didn't say waste of time, I said overkill. If 10 minutes looking at what the trace told you and inspecting the jsp can get you the answer then firing a JVM and attaching is overkill. Trying to solve a problem by looking at the code is worth the effort before falling back on other tools. VisualVM is an awesome tool. I encourage learning it. But those tools aren't always available and I prefer building your investigative muscles first. – Jerry Hoerig Mar 19 '13 at 22:16
  • Permgen problems are usually an issue of generating a large volume of classes that overflow Eden and Tenured space overflowing into ancestor space. If it's happening during page generation that's a good place to start. – Jerry Hoerig Mar 19 '13 at 22:19
1

1) Limiting MaxPermSize to 512m probably isn't a good idea. I would definitely take it out.

2) It couldn't hurt to consider increasing -Xmx.

3) Here are some good links:

4) The most important thing is to profile your app as it's running to see if you can figure out exactly what is consuming your PermGen. Here are some options:

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • Man, by default maximum allowed PermGen is less than 100m, so increasing that limit to 512m is definitely a good idea. – Nikem Mar 20 '13 at 10:25
1

Maybe i am wrong, but the issue seems related to an incorret use of Jasper... have you investigated the accepted resone to OutOfMemoryError: PermGen Space -- Jasper Report with Spring running on Tomcat ?

Community
  • 1
  • 1
Carlo Pellegrini
  • 5,656
  • 40
  • 45
  • 1
    A good suggestion, if the OP happens to be using Jasper. I would also 1) remove -XX:MaxPermSize, 2) set -Xmx=2048m, and, most important, 3) profile with MAT or JVisualVM. IMHO... – paulsm4 Mar 19 '13 at 21:41
  • Surely JVisualVM could help. Also some code from the incriminated jsp... So huge a PermGen comsumption smells of recursive compilations to me – Carlo Pellegrini Mar 19 '13 at 22:03