What to do about running out of PermGen space.

Document ID : KB000030396
Last Modified Date : 14/02/2018
Show Technical Document Details


When running an APM agent you encounter this message in the Agent logs:

java.lang.OutOfMemoryError: PermGen space



"The permanent generation is used to hold reflective data of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations." 

So this is in addition to the heap specified with -Xmx JVM Startup argument.


The simple solution would be to increase the PermSize by changing  -XX:MaxPermSize. But this is a workaround until processing some future class breaks things. And it will not solve a PermGen memory leak issue.


The better solution is to determine which class being invoked is causing the issue or is there a PermGen memory leak. This includes:

- Adding -verbose wherever you invoke javaagent path_name\agent.jar

- Reviewing in autoprobe log with classes are being called and eliminate any unneeded or troublesome classes

- Removing any custom pbds .


Note that in Java 8, the PermGen approach was replaced by using Metaspace instead.



http://www.infoq.com/articles/Java-PERMGEN-Removed                                                                          -- Explains what happened to PermGen in Java 8

http://www.javacodegeeks.com/2013/12/decoding-java-lang-outofmemoryerror-permgen-space.html  -- Good Overview on PermGen and common issues