Can't understand "out of memory" kills

Rogerio

Well-Known Member
Sep 26, 2016
78
15
8
Sao Paulo, Brazil
cPanel Access Level
Root Administrator
Hello,

my server has 4 Gb of RAM and is not overloaded. Sometimes some PHP scripts use more memory and I receive "out of memory" messages, but there is no out of memory... and it kills MySQL, what is a big problem.

How to fix this?

----------

Out of memory: ⚠ The process “mysqld” was terminated because the system is low on memory.

In order to avoid a system crash due to low memory, the kernel terminated the process named “mysqld” with the PID “1311”.

(...)

Process OOM Score 66
Status Out of Memory ⚠
Memory Information
Used 602 MB
Available 3.11 GB

Installed 3.7 GB

[308508.568672] [12514] 1005 12514 63883 11265 124 566 0 php-cgi
[308508.572096] [12516] 1005 12516 63883 11018 123 813 0 php-cgi
[308508.575429] [12517] 1005 12517 63883 11345 123 488 0 php-cgi
[308508.578967] [12518] 1005 12518 64331 12033 126 302 0 php-cgi
[308508.582312] [12522] 1005 12522 64014 11704 127 301 0 php-cgi
[308508.585508] [12533] 1005 12533 57622 5442 109 120 0 php-cgi
[308508.589325] [12557] 1002 12557 55306 3297 107 13 0 php-cgi
[308508.594133] [12558] 1002 12558 54101 1978 105 17 0 php-cgi
[308508.597030] Out of memory: Kill process 1311 (mysqld) score 66 or sacrifice child
[308508.599799] Killed process 1311 (mysqld) total-vm:1803856kB, anon-rss:206380kB, file-rss:0kB, shmem-rss:0kB
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,269
313
Houston
Hi @Rogerio


So when this happens it's the Linux kernel killing the process to ensure that processes running and those integral to the system which have reserved memory have enough to run. When a process is killed like this and you get the email from cPanel it's not always able to show you what's actually occurring on the server. What might be useful is to check sysstats. The following should give an idea of used memory for the last few hours:

Code:
sar -r
 
  • Like
Reactions: Rogerio

Rogerio

Well-Known Member
Sep 26, 2016
78
15
8
Sao Paulo, Brazil
cPanel Access Level
Root Administrator
Hello,
the CPU was high in that moment, indeed. Well, at least, mysqld was restarted automatically.
But sometimes it kills other services like snmpd that I need to restart manually.
Thank you.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,269
313
Houston
Hi @Rogerio


If you find it's occurring often and it's legitimate usage you might need to look at increasing the amount of memory on the server. This really shouldn't be occurring very frequently.


Thanks!
 
  • Like
Reactions: Rogerio