What does -XX:MaxPermSize do?

JavaJvmJvm Arguments

Java Problem Overview


Specifically, why would it help to fix a PermGen OutOfMemoryError issue?

Also, bonus points for an answer that points me to the documentation on JVM arguments...

Java Solutions


Solution 1 - Java

The permanent space is where the classes, methods, internalized strings, and similar objects used by the VM are stored and never deallocated (hence the name).

This Oracle article succinctly presents the working and parameterization of the HotSpot GC and advises you to augment this space if you load many classes (this is typically the case for application servers and some IDE like Eclipse) :

> The permanent generation does not have a noticeable impact on garbage > collector performance for most applications. However, some > applications dynamically generate and load many classes; for example, > some implementations of JavaServer Pages (JSP) pages. These > applications may need a larger permanent generation to hold the > additional classes. If so, the maximum permanent generation size can > be increased with the command-line option -XX:MaxPermSize=.

Note that this other Oracle documentation lists the other HotSpot arguments.

Update : Starting with Java 8, both the permgen space and this setting are gone. The memory model used for loaded classes and methods is different and isn't limited (with default settings). You should not see this error any more.

Solution 2 - Java

-XX:PermSize -XX:MaxPermSize are used to set size for Permanent Generation.

Permanent Generation: The Permanent Generation is where class files are kept. These are the result of compiled classes and JSP pages. If this space is full, it triggers a Full Garbage Collection. If the Full Garbage Collection cannot clean out old unreferenced classes and there is no room left to expand the Permanent Space, an Out‐of‐ Memory error (OOME) is thrown and the JVM will crash.

Solution 3 - Java

In Java 8 that parameter is commonly used to print a warning message like this one:

> Java HotSpot(TM) 64-Bit Server VM warning: ignoring option > MaxPermSize=512m; support was removed in 8.0

The reason why you get this message in Java 8 is because Permgen has been replaced by Metaspace to address some of PermGen's drawbacks (as you were able to see for yourself, one of those drawbacks is that it had a fixed size).

FYI: an article on Metaspace: http://java-latte.blogspot.in/2014/03/metaspace-in-java-8.html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionZefiraView Question on Stackoverflow
Solution 1 - JavaDenys SéguretView Answer on Stackoverflow
Solution 2 - Javastones333View Answer on Stackoverflow
Solution 3 - JavaAndrewBourgeoisView Answer on Stackoverflow