Server performance problems can be quite frustrating, especially when they happen again and again to the server. One common issue many VPS servers owners face is Server “Out of Memory” (OOM) errors. In this blog, we’ll explain what these errors exactly mean, why they happen, also in this memory issue, how swap space is involved, and what steps can be taken to reduce the problem.
This blog is based on a real support case where a VPS server experienced repeated out of memory problems, MySQL crashes, and high or swap usage gets full.
Server Out of Memory (OOM) Error : what is it exactly?
On the server every process like websites, databases, emails and background tasks needs memory to work them properly. In this usage, the server runs out of memory when the server is out of usable RAM.
When the server / system can’t find enough free memory then server will do below possible:
- The Linux kernel steps in to protect the server due to memory
- It automatically starts to kill one process
- This prevents the whole server from crashing ,as server crash chances are high when server faces out of memory.
We are taking a case where the process that was repeatedly killed was MySQL, which is very important and responsible for handling website databases.
Why MySQL gets Affected ?
MySQL is a memory-heavy service. On busy servers, it can use a large amount of RAM, especially when:
Normally MySql service is memory-heavy. However, on busy servers, it uses large amount of RAM, below are examples of them:
- Multiple websites are active on the server
- Traffic spikes occur for large number of the hits
- Backup jobs run at the same time during peak hours
- Image optimization & Caching plugins are active and that also utilize the memory
When the Server OOM event occurs, time logs show that MySql was using hundreds of megabytes of memory. But when memory became critically low, the system stopped Mysql to free up the space.
Servers based on cPanel have introduced the feature in which it automatically restarts the MySQL service, so downtime is often short, but if this is happening repeatedly then such a crash can cause performance issues.
Increased Risk of Server OOM Situations when no SWAP space:
When there is no SWAP space available, operating system has fewer options to reclaim the memory, if memory is exceeded due to active process then OOM killer will be triggered more frequently, and it will terminate the random processes to free the memory, this random termination makes it challenging to predict which application will crash, and it will potentially impact the critical services running.
Swap Space and Why It Matters
Normally SWAP space is a disk space used as an extra memory when the RAM is full, however it is slower than the real RAM, but it helps to prevent sudden server crashes.
In this case:
- Swap space is enabled and active
- An additional 8GB of swap is added
- This helped stabilize the server temporarily instead of direct crash
However, swap is not a permanent fix. If swap usage becomes very high or full, it usually means the server is under memory pressure and needs optimization.
However, swap is not a permanent fix, when swap usage becomes very high or full, it normally means the server is under memory pressure and this needs optimization.
Signs of Memory Pressure
Below are some common signs in this case :
- Repeated out-of-memory alerts
- MySQL being killed by the system
- High load averages during peak times
- Swap space gradually filling up
- Performance slowing down
These signs tell us that the server is trying to handle more work than its available memory comfortably allows.
If you come across these signs then it tells us that the server is trying to handle more work than its available memory allows to do comfortably.
Below are the possible Causes of High Memory Usage
Based on the logs and investigations, few likely causes are below:
1. MySQL Under Peak Load
MySQL usage increased during busy times, especially when backups or heavy queries are running at same time
2. WordPress Caching and Image Plugins
A caching plugin was suspected of performing third-party image optimization or hotlink-related tasks. These can consume extra memory without being obvious
3. Multiple PHP-FPM Processes
Several PHP-FPM pools were active at the same time, each using its own memory
4. Background Jobs
Cron jobs, backups, and email services are all running together and it will be increasing memory demand
Diagnostic Steps Used
To understand the issue better, the following checks are recommended and used:
You can monitor the memory and swap usage in real time.
Check MySQL status using:
mysqladmin status Review system logs
/var/log/messages
/var/log/mysql/error.log Review OOM (Out of Memory) logs using “dmesg“
These steps will help to identify the exact service that is using the most memory and exact time when it’s utilizing it.
Below are the solutions That Helped:
Several actions need to be taken to reduce the issue:
- Make sure the SWAP Space Added
Extra swap helped prevent immediate crashes and give the system breathing room to avoid crashes.
- Re-enable the Hotlink Protection
It will reduce the unwanted image requests from third party websites.
- Remove Problematic Plugin
In some cases, few plugins are there, those causing the high memory usages, find them and disable such plugins.
- Continue Monitoring
Ongoing monitoring will make sure the memory is free after the crash and services are restarted properly.
Things that can be done to prevent future OOM issues ?
Below are the best practices that will avoid repeated memory problems:
- You can optimize MySQL configuration
- Remove or disable the unnecessary WordPress plugins
- Avoid running heavy tasks at the same time, make sure to set different times
- Monitor swap usage regularly
- Upgrade server RAM if memory usage remains consistently high
Review backup schedules to run during low-traffic hours.
CONCLUSION :
Server Out of Memory (OOM) errors can significantly affect website performance, database stability, and overall server reliability. As seen in this case, repeated MySQL crashes and high swap usage are strong indicators that the server is operating under heavy memory pressure.
While enabling swap space can provide temporary relief and prevent sudden crashes, it should not be considered a permanent solution. The real fix often involves identifying memory-intensive services, optimizing database configurations, reducing unnecessary plugins, and scheduling heavy tasks during low-traffic periods.
By actively monitoring server resources and implementing optimization strategies, administrators can reduce the risk of recurring OOM events and ensure smoother, more stable server performance.
Frequently Asked Questions (FAQs)
1. What causes an Out of Memory (OOM) error on a server?
An Out of Memory (OOM) error occurs when a server runs out of available RAM and cannot allocate memory to running processes. When this happens, the Linux kernel activates the OOM killer, which automatically terminates one or more processes to free memory and prevent the entire system from crashing.
2. Why does MySQL often get killed during OOM events?
MySQL is a memory-intensive service, especially on servers hosting multiple websites or handling high traffic. During peak loads, MySQL may consume a large portion of available RAM for queries, caching, and connections. If memory becomes critically low, the system may terminate MySQL to free resources.
3. What is swap space and why is it important?
Swap space is disk space used as virtual memory when RAM is fully utilized. Although it is slower than physical RAM, swap helps prevent immediate crashes by temporarily storing inactive memory pages. However, excessive swap usage often indicates that the server requires memory optimization or a RAM upgrade.
4. How can I check if my server experienced an OOM event?
You can verify OOM events by checking system logs using commands such as:
dmesg | grep -i oomgrep -i "out of memory" /var/log/messagesgrep -i "killed process" /var/log/messages
These logs will show which process was terminated due to memory exhaustion.
5. How can I monitor memory and swap usage on a Linux server?
Common commands to monitor memory usage include:
free -m– Displays RAM and swap usagetoporhtop– Shows real-time resource usagevmstat– Displays system memory statistics
These tools help identify which services are consuming the most memory.
6. Can WordPress plugins cause high memory usage?
Yes. Certain WordPress plugins, especially caching, image optimization, backup, and security plugins, can consume significant memory resources. Poorly optimized plugins may increase RAM usage and contribute to OOM events.
7. Is adding more swap space a permanent solution to memory issues?
No. Adding swap space only reduces the risk of sudden crashes but does not fix the underlying problem. If swap usage is consistently high, the server likely needs performance optimization, workload balancing, or additional RAM.
8. What are the best ways to prevent recurring OOM errors?
Some best practices include:
- Optimizing MySQL configuration
- Limiting PHP-FPM worker processes
- Removing unnecessary plugins and background services
- Scheduling backups during low traffic periods
- Monitoring server resources regularly
- Upgrading RAM if the workload increases
If your server is experiencing frequent crashes, high memory usage, or repeated Server OOM errors, it may be time for a deeper performance analysis. Our server experts can help you diagnose memory issues, optimize MySQL and PHP configurations, and stabilize your infrastructure for better reliability.
Contact our support team today to keep your servers running smoothly and efficiently.

