≡ Menu

Troubleshooting GC: Running out of PermGen space

If there is one memory related issue that strikes you off guard, that must be ‘running out of permgen space’. Fortunately it is easy to fix.

What are the symptoms of running out of Permgen space ?

1. Unexpected application errors
2. Unable to start the application
3. java.lang.OutOfMemoryError:PermGen space in the log file.

What causes to run out of Permgen space ?

Permgen is a an area of Heap that stores class objects and interned strings. You don’t have to get into the details but know that permgen area will fill up if you load tons of classes, which will be the case if you load numerous third party libraries. Specifically, some of the ‘javaagent’ libraries (an important component in APM tools) are known to demand large permgen space.

The default permgen size (this varies by version and platform, typically 64MB) may not be enough in some cases especially if you use several third party libraries as mentioned above.

How to prevent Heap ‘running out of Permgen space’ ?

1. Try pumping up the permgen space to 256MB or more if you need

-XX:MaxPermSize=256m

2. Ensure that you are NOT loading tons of third party libraries that you don’t need. Check the classpath, java library path and startup logs to see if you find any clue.

3. Upgrade to Java 1.8. Note that there is NO permgen in java 1.8 onward. It has been replaced by Metaspace. But note that this may not be cure-all. Check out my other post: One important change in Memory Management in Java 8

Moving on, you may not see any error at all in your log files but your application could be extremely slow due to this lethal Heap related issue – Excessive garbage collection.

Coming up: Troubleshooting GC: Excessive garbage collection

Previous: Troubleshooting GC: Heap Fragmentation

 

{ 0 comments… add one }

Leave a Comment