HidenCloud
English
Ask or search…
K
Links
🔃

Server Restarting / killed?

Handling Server Restarts and Memory Issues. Server Restarting: OutOfMemory = true

Understanding the Issue: Out of Memory Error and Server Restarts

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.
Server -> System -> Audit Logs -> OutOfMemory = true

The OOM Killer

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.
Server -> Configuration -> Startup Parameters

SERVER_MAX_RAM Variable

The SERVER_MAX_RAM variable is a critical configuration parameter in HidenCloud's hosting environment. It controls the maximum amount of RAM allocated to Java-based servers. By default, this variable is set to -1, allowing Java to utilize the entire RAM available in your server plan. Setting SERVER_MAX_RAM to a specific value limits Java's memory usage, helping to prevent the activation of the OOM Killer. It's important to note that increasing this value beyond the physical RAM of your server plan won't enhance performance, as it cannot exceed the actual server plan limits.
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 room 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 the Issue Persists

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.

Final Recommendations

  • 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.