0

I got the following error in browser when log into the system

java.lang.RuntimeException: javax.servlet.ServletException: java.lang.OutOfMemoryError: PermGen space com.opensymphony.sitemesh.webapp.decorator.BaseWebAppDecorator.render(BaseWebAppDecorator.java:39) com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:84)

Shan007
  • 5
  • 4

4 Answers4

2

java.lang.OutOfMemoryError

Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector. OutOfMemoryError objects may be constructed by the virtual machine as if suppression were disabled and/or the stack trace was not writable.

Increase the heap size of your JVM

It is possible to increase heap size allocated by the JVM by using command line options Here we have 3 options

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size

Common causes of OutofMemory in PermGen is ClassLoader. Whenever a class is loaded into JVM, all its meta data, along with Classloader, is kept on PermGen area and they will be garbage collected when the Classloader which loaded them is ready for garbage collection. In Case Classloader has a memory leak than all classes loaded by it will remain in memory and cause permGen outofmemory once you repeat it a couple of times.

Now there are two ways to solve this: 1. Find the cause of Memory Leak or if there is any memory leak. 2. Increase size of PermGen Space by using JVM param -XX:MaxPermSize and -XX:PermSize.

underdog
  • 4,447
  • 9
  • 44
  • 89
0

Either optimize your program or increase java heap size with run time parameters.(-Xxx)

Shriram
  • 4,343
  • 8
  • 37
  • 64
0

java.lang.OutOfMemoryError: PermGen space

Two step solution.

Step One : Alter your application launch configuration and add (or increase if present) the -XX:MaxPermSize parameter . This is a temporary step as if this is a live system most probably the extra memory will also get filled at some time in the future.But this will fix the error for now.

Step two : Release unnecessary resources. Make sure all database connections are closed. Load and unload classes judiciously.restructure you program to work with small amounts of data at a time. Analyse and Fix memory leaks

Raj
  • 1,945
  • 20
  • 40
0

It is important to know, whether the PermGenError occurs after every depolyment, or after few ones.

If it is the first case, just increase the memory size for your PermGen.

If it is the second, you have some dead cows in your code. In this case, increasing memory size will only postpone the error, as your memory is still growing in size after every deployment. You have to profile your app like for example with jvisualvm (here is nice tutorial) and find some dead cows. It is important to understand, that PermGenError is not about the classes itself, but about classLoaders (Classloader leaks: the dreaded "java.lang.OutOfMemoryError: PermGen space" exception).

In my case (Glssfish server), the problem was the Log4j2 libs added to the web app. I had to add them also to the server libs (domain-dir/lib), so that according to the Glassfish Class Loaders Hierarchy they where loaded by the Common classLoader.

Szarpul
  • 1,531
  • 11
  • 21