Question

Getting regular "Out of memory: Kill process". How to resolve this isse?

Posted July 30, 2013 76.7k views
Regularly I got the following message in syslog file: "Out of memory: Kill process 837 (mysqld) score 59 or sacrifice child". This is really annoying. I already created a swapfile using this tutorial "https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04" but I still get error. Could you please tell me how to fix this issue? My droplet is a $5 one with 512Mb RAM. THe distro is Ubuntu 13.04 x64. (the funny thing is that default mysql configuration worked perfectly on my previous server (VPS Gandi with only 256Mb RAM)
2 comments
  • I’m getting the same thing on $10 plan for apache2 (running wordpress and have basically zero traffic except for myself.

  • Try disabling OOMKiller using this command:

    echo 1 > /proc/sys/vm/overcommit_memory

    You can make it permanent with /etc/sysctl.conf by adding vm.overcommit_memory = 1 and then running sysctl -p

    Just be aware disabling OOMKiller will have negative effects if you actually run out of memory.

    I found even with loosening the ratio to 60% it still killed off my processes with less than 60%.

    Disabling it entirely by setting to 1 fixed my problem I think :)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
36 answers

Try to use a swap file.
Getting this error with a nodejs process et resolved since using a swap

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.

Restarting apache2 and mysql is only a temporary solution, not fixing the root cause.

I am facing same issue with $5 plan. My website is not working even. Can anyone from digital ocean helps us here.

Follow the swap tutorial. It solved it for me. I have the 5$ droplet and it works fine now :)

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.

I used the suggestions at https://tech.labelleassiette.com/how-to-reduce-the-memory-usage-of-mysql-61ea7d1a9bd to resolve this issue.

A few notes to help clarify:

1) Update your my.conf file to something similar to below (tweak as desired):

#
# Note the new values are after the included files below
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

[mysqld]

read_buffer_size             = 60K
sort_buffer_size             = 1M
innodb_buffer_pool_size      = 64M
tmp_table_size               = 8M
max_connections              = 25

2) If you want to run the script that was shared at the bottom of the linked webpage, you need to save it as a file (e.g. sudo nano mysqlinfoscript), and you may want to add some mysql credentials to the first uncommented line (replacing the username and password) as below:

mysql -u username -p'password' -e "show variables; show status" | awk '

3) To execute the script (assuming you named it mysqlinfoscript) run:

bash mysqlinfoscript

4) It’s unsafe to leave the username/password in the script so you may want to remove that when finished.

5.) You’ll need to restart mysql after updating my.conf:

sudo service mysql restart
You can try tweaking /etc/mysql/my.cnf or resizing your droplet to a larger plan.
It might not necessarily be a MySQL problem. Sometimes, other programs hog a server's memory - leaving MySQL too little memory to work with.

Are you running Apache? If so, you should fine-tune Apache2 and MySQL memory usage.

Is it too late for you to copy the config from VPS Gandi, so you can compare it to the config on your droplet?

Guys, I have the same problem.
“You can try tweaking /etc/mysql/my.cnf”
“You should fine-tune Apache2 and MySQL memory usage”

  • is there any step by step explanation of these two?

Thank you!

Same problem here. on $20 per month plan and zero traffic, mysql (on wordpress) keeps stopping (out of memory).

I have the same issue… Really annoying.

Previous 1 2 3 4 Next