What's the ideal permsize Minecraft?

2.6K    Asked by AmeliaArnold in Java , Asked on May 24, 2024

I have a FTB Unleashed 1.1.7 server running and I have been getting the following error as of lately "java.lang.OutOfMemoryError: PermGen space"

According to this thread: Dealing with “java.lang.OutOfMemoryError: PermGen space” error , the recommended flags are

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled along with setting the MaxPermSize -XX:MaxPermSize=128M.

What is the ideal MaxPermSize? Will increasing the MaxPermSize (256

Answered by Amit jaisawal

While I do agree to some point with the existing answers, increasing to -XX:MaxPermSize=512M will help and even up to -XX:MaxPermSize=1G should not hurt, assuming your server has that amount of physical RAM, a word of advice regarding the total heap size, which is configured by increasing -Xmx=xGB.


In general this will increase the available memory for the program, which is good, since the JVM (Java Virtual Machine, essentially the program running your minecraft server) will have more memory to put 'stuff' into. At a certain point, there will however be a great drawback. As you go into the 10s of gigabytes, the JVM becomes more and more inefficient to handle this much memory without advice.

As more and more memory is needed, you need to tell the JVM what exactly the memory is primarily used for (this depends whether your java objects are rather short- or long-lived). I am not sure regarding how permsize Minecraft handles this memory, as I come from another java field (J2EE), but the bigger the total RAM, the more likely you need to tune your server to the specific requirement for the application.

Specifically you will need to tune the garbage collector to rather have minimal stop-the-world pauses (basically where your server completely stands still and seemingly does nothing). Using -XX:+UseConcMarkSweepGC will help that a lot. Using -XX:CMSClassUnloadingEnabled will only help to keep your PermGen (-XX:MaxPermSize) clean but not keeping your overall heap clean. For the former case, there are literally dozens of settings that need to be considered.

TL;DR:

For a very big server there is a lot more to tune than just the -XX:MaxPermSize. A PermSize of around -XX:MaxPermSize=1G and a heap around -Xmx=4G to -Xmx=6G should still be fairly safe. I would not go much beyond this to keep server performance.

Of course the MaxPermSize + Xmx should never be higher than the RAM installed in your computer. It will start swapping which will reduce performance by some magnitudes.



Your Answer

Answers (2)

@RanjanaDiya tomar's answer is very detailed and comprehensive, thank you for that Raft Wars has been fixed.

2 Months

In previous versions of Minecraft, the PermSize parameter was used to specify the initial size of the Permanent Generation memory space when running the game with the Java Virtual Machine (JVM). However, PermSize is no longer used in recent versions of Java (Java 8 onwards) as the Permanent Generation was replaced by the Metaspace.


In Java 8 and later, you typically don't need to specify PermSize directly. Instead, you can adjust the Metaspace size using the -XX:MaxMetaspaceSize parameter. The optimal value for this parameter depends on various factors such as the number of mods, the size of your world, and the available system memory.

A general recommendation is to allocate enough memory to Metaspace to accommodate the classes and metadata your Minecraft server requires without running out of memory. You can experiment with different values based on your server's needs and monitor its performance to find the optimal setting.

For example, you might start with a value like -XX:MaxMetaspaceSize=256M and adjust it up or down as needed based on performance metrics and any errors related to Metaspace exhaustion.

Remember to always monitor your server's memory usage and performance to ensure it's running optimally.


7 Months

Interviews

Parent Categories