Memory Leak Processes

OOM Killer Resolutions: Processes with High Risk of Memory Leak

Processes in this group are among the most likely causes of out-of-memory issues. Review the recommendations according to the affected server role and process name.

Load Balancers

When a load-balancer process is terminated, the handled traffic may simply require more memory for normal operation.

ProcessResolution
varnishdIncrease the RAM limit for the affected node.

Java Application Servers

Review the JVM memory settings and adjust them to match the application requirements.

java -Xmx2048m -Xms256m
  • -Xmx defines the maximum JVM heap size.
  • -Xms defines the initial heap size.
  • Also review -Xmn when tuning the young-generation heap.
  • Remember that a JVM uses additional memory outside the Java heap.
  • Review garbage-collector settings when application-specific tuning is required.
ProcessResolution
javaReview the xmx, xms, and xmn settings and configure them according to the application’s actual memory requirements.

PHP Application Servers

For Apache-based PHP servers, inspect the average memory consumed by each httpd process, disable automatic tuning when manual values are required, and reduce the process limits.

(Total_RAM - 5%) / Average_RAM
  • Remove the automatic-configuration marker from /etc/httpd/httpd.conf.
  • Use the calculated result to reduce ServerLimit and MaxClients.
  • When memory per process keeps increasing, reduce MaxRequestsPerChild to approximately 1000–5000.

For NGINX PHP, connect through SSH and inspect the PHP-FPM process sizes using tools such as ps or top.

  • If most PHP-FPM processes use about 50–100 MB, disable auto-configuration and reduce max_children.
  • If process sizes vary significantly or exceed about 200–300 MB, inspect the application for a memory leak, optimise the code, or reduce max_requests_per_child.
ProcessResolution
httpdCheck average RAM per process, remove the autoconfiguration marker, and lower ServerLimit and MaxClients using the documented formula.
httpd.itkApply the same Apache memory-management procedure as for httpd.
lsyncdIncrease node RAM when the application workload requires more memory.
nginxDisable automatic configuration and tune the relevant process limits for the application.
phpDisable automatic configuration and tune the appropriate PHP process settings.
php-fpmDisable automatic configuration and tune the appropriate PHP-FPM settings.
php-fpm7.0Disable automatic configuration and tune the appropriate PHP-FPM settings.
php7.0Disable automatic configuration and tune the appropriate PHP settings.

Ruby Application Servers

Memory leaks are relatively common in Ruby applications. Start by inspecting and optimising the application code. Increasing the node RAM is an alternative when the workload legitimately requires more memory.

ProcessResolution
httpdCheck average RAM per process, remove the autoconfiguration marker, and lower ServerLimit and MaxClients.
httpd.itkApply the same Apache tuning procedure.
bundleIncrease the node RAM when the operation requires additional memory.
gemIncrease the node RAM when the operation requires additional memory.
rubyInspect and optimise the code or allocate more RAM to the node.

Python Application Servers

For Apache-based Python servers, use the same httpd process-sizing procedure described for PHP. When another Python process is killed, the application may simply need more RAM.

ProcessResolution
httpdCheck RAM per process, remove the autoconfiguration marker, and reduce ServerLimit and MaxClients.
httpd.itkApply the same Apache tuning procedure.
lsyncdIncrease node RAM when the application requires more memory.
pipCheck for a stalled network download. Otherwise, allocate more RAM to the node.
pythonAllocate more RAM when the application requires additional memory.
python2.7Allocate more RAM when the application requires additional memory.

Node.js Application Servers

Restart the container to restore the terminated process. When the issue returns, increase the RAM limit because the application or build operation may require more memory.

ProcessResolution
lsyncdIncrease the node RAM.
gruntIncrease the node RAM.
nodeIncrease the node RAM.
npmIncrease the node RAM.
phantomjsIncrease the node RAM.

Database Servers

MySQL

For InnoDB, inspect the current buffer usage:

SHOW ENGINE INNODB STATUS\G;
  • If buffers use more than about 80% of the container RAM, reduce innodb_buffer_pool_size in /etc/my.cnf.
  • When buffer usage is not excessive, allocate more RAM.
  • Review MySQL logs for warnings and recommendations.
ProcessResolution
mysqldInspect InnoDB buffers, reduce innodb_buffer_pool_size when necessary, and review MySQL logs.
httpdApply the Apache process-sizing and autoconfiguration procedure.

PostgreSQL

ProcessResolution
postgresIncrease the RAM limit for the database node.
httpdApply the Apache process-sizing and autoconfiguration procedure.

Redis

ProcessResolution
redis-serverIncrease the RAM limit for the Redis node.

Common Processes for Different Stacks

ProcessStackResolution
httpdPHP, Ruby, Python, MySQL, PostgreSQLCheck average process RAM, remove the autoconfiguration marker, and reduce ServerLimit and MaxClients.
lsyncdPHP, Node.js, PythonIncrease node RAM.
httpd.itkPHP, Ruby, PythonApply the Apache memory-tuning procedure.
procmailAnyRestart the container.
vsftpdAnyRestart the container.
yumAnyRestart the container.
cc1Third-partyIncrease node RAM.
clamdThird-partyIncrease node RAM.
ffmpegThird-partyIncrease node RAM.
firefoxThird-partyIncrease node RAM.
newrelic-daemonThird-partyRestart the primary stack service, such as NGINX, Tomcat, or Node.js.
Repeated events: Increasing RAM can restore service, but repeated OOM alerts should be followed by code, process, database-buffer, or runtime-configuration analysis.

What’s next?