๐Server Restarting / killed?
Handling Server Restarts and Memory Issues. Server Restarting: OutOfMemory = true
Last updated
Handling Server Restarts and Memory Issues. Server Restarting: OutOfMemory = true
Last updated
Copyright ยฉ 2024 HidenCloudโข by HidenNetworkโข - All rights reserved. | E: info@hidencloud.com | T/WA: +34624027199 | ID: 6H58JSXC8SCC2
At HidenCloud, we prioritize the smooth operation and reliability of your server. However, you may occasionally encounter server restarts due to an "Out of Memory" (OOM) error. This is commonly related to the way Java, the programming language used by many applications including Minecraft, manages memory.
A critical system component to understand is the OOM Killer. This is a mechanism in the Linux operating system, which HidenCloud servers utilize, designed to handle low memory situations. When your server consumes all available memory, the OOM Killer is triggered to free up resources. It does this by terminating processes, which can unfortunately include your server, leading to restarts.
Adjusting Memory Settings to Prevent OOM
To mitigate this issue, itโs essential to configure your server's memory settings correctly. Java, by default, can use all available memory, which might trigger the OOM Killer. You can adjust these settings through two key parameters:
Xms (Initial Memory Allocation): This setting determines the initial amount of memory Java allocates on startup. (You can't modify this)
Xmx (Maximum Memory Allocation): This is the maximum amount of memory Java is allowed to use. (You can modify this)
You can modify the server RAM (Xmx) through: Server -> Configuration -> Startup Parameters -> SERVER_MAC_RAM Variable.
The SERVER_MAX_RAM
parameter in HidenCloud controls the maximum RAM allocated to Java servers, impacting the Garbage Collector (GC) performance. By default, it is set to "total server RAM - 512MB" to reserve some memory for system processes. Setting this value too high can lead to longer GC pauses, while too low can cause more frequent GC runs, both affecting performance. It should not exceed the RAM allocated to your server, as this may trigger the OOM Killer and stop the server.
To set this variable, YOU MUST FOLLOW THE FOLLOWING SCHEME: -Xmx{RAM_in_megabytes}M
. For example: -Xmx2048M
.
You need to leave a minimum difference of 512MB or an optimal difference of 1500MB for Java to use as a buffer or for garbage collection. For example, if you have a server with 2GB of RAM, which is equivalent to 2048MB, and you set the SERVER_MAX_RAM
variable to -Xmx1024M
(1GB), you will notice that the server can reach up to 1500MB of usage. This happens because Java uses the additional space as a buffer. The buffer space allows Java to manage memory more efficiently, allocating ram for temporary data and garbage collection processes. This buffer is crucial for the smooth operation of Java applications, as it helps to prevent out-of-memory errors by providing a cushion of available memory that Java can utilize for managing temporary and unneeded data.
When configuring these settings, it's crucial to allocate less memory than the total available on your server. For example, if your server has 8000M of memory:
Do Not Allocate the Full 8000M to Java: This leaves no memory for other essential system processes, risking an OOM situation.
Allocate Around 6500M for Java: This creates a buffer of approximately 1500M, ensuring there is memory available for the operating system and other processes.
This configuration helps in preventing the server from using all available RAM, reducing the likelihood of the OOM Killer being activated.
If your server continues to experience restarts due to memory issues:
Contact HidenCloud Support: Our team can assist you with further troubleshooting and configuration. HidenCloud Support
Disabling the OOM Killer: As a last resort, HidenCloud support can disable the OOM Killer for your server. However, this is generally not recommended as it can lead to system instability.
Regularly monitor your serverโs memory usage.
Consult with HidenCloud support for optimal memory settings.
Consider upgrading your server plan if memory issues persist.
By following these guidelines and adjusting your serverโs memory settings, you can significantly reduce the occurrence of "Out of Memory" errors and server restarts, ensuring a smoother and more reliable experience on HidenCloud.