Interesting thing I did not know about Java – PermGen. Apparently other than just the stack (local variables and methods) and the heap (everything else), java uses this extra storage which can also cause OOMs.
PermGen is where a few very long-lived types of objects are persisted in Java, such as class definitions and ‘intern’ed Strings. It uses separate storage from the heap and the stack. If you run out of PermGen you will get out of memory errors. If you run very low you will get a JVM that spends all its time garbage collecting.
Few things I came about when I googled around:
- Never call System.gc(). It does not know the best time to garbage collect, only the JVM really does. (http://bit.ly/zIfp0B)
- Common causes of OOM in PermGen is ClassLoader. Whenever a class is loaded into JVM, all its meta data, along with Classloader, is kept on PermGen are and they will be garbage collected when the Classloader which loaded them is ready for garbage collection. In case Classloader has a memory leak then all classes loaded by it will remain in the memory and cause PermGen OOM once you repeat it a couple of times.
- http://blogs.oracle.com/fkieviet/entry/classloader_leaks_the_dreaded_java [definitely read this!]
- http://www.integratingstuff.com/2011/07/24/understanding-and-avoiding-the-java-permgen-space-error/ [also this one]
Luckily I’ve never had to deal with PermGen OOM before. Apparently it’s hell-of-a-job debugging this issue.
From The SDE Tip – Amazon
Popularity: 1% [?]