Setting the Java Virtual Machine Heap Size

From BukkitWiki
Jump to: navigation, search

Allocating some more RAM to your server (more specifically, Java's heap space) may help with certain lag-related problems. However, you must consider your internet connection as a bottleneck as well. If bumping your RAM allocation to Java's heap doesn't help, you may wish to remove some plugins. If that still doesn't resolve the issue, you should get a better internet connection. You should make sure you have more physical RAM than your allocated heap space, and required for your OS, or server performance can actually suffer. An overly large initial heap size can also degrade performance under certain circumstances, thus important to pick a balanced heap size for your server load.

To add more RAM to the heap, you should pass the flags -Xms and -Xmx to the JVM. -Xms specificates how much memory Java will initially allocate for heap space, and -Xmx will be the maximum heap space that can be allocated.


java -Xms512m -Xmx2048m -jar craftbukkit.jar tells the JVM to allocate 512MB for heap space when it launches, and it can grow to 2048MB before stopping.

The m following the 512 and 2048 indicates the value is in Megabytes. You can use g if you want to allocate memory in Gigabytes.