Why is the default size of PermGen so small?

djangofan picture djangofan · Nov 20, 2012 · Viewed 29.8k times · Source

What would be the purpose of limiting the size of the Permgen space on a Java JVM? Why not always set it equal to the max heap size? Why does Java default to such a small number of 64MB? Are they trying to force people to notice permgen issues in their code by doing this?

If my app uses 85MB of permgen, then it might be safe to set it to 96MB but why set it so small if its just really part of the main heap? Wouldn't it be efficient to allow the JVM to use as much PermGen as the heap allows?

Answer

Frank Pavageau picture Frank Pavageau · Nov 20, 2012

The PermGen is set to disappear in JDK8.

What would be the purpose of limiting the size of the Permgen space on a Java JVM?

Not exhausting resources.

Why not always set it equal to the max heap size?

The PermGen is not part of the Java heap. Besides, even if it was, it wouldn't be of much help to the application to fill the heap with class metadata and constant Strings, since you'd then get "OutOfMemoryError: Java heap size" errors instead.