LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-04-2015, 12:30 PM   #1
gombi
LQ Newbie
 
Registered: Jun 2015
Posts: 9

Rep: Reputation: Disabled
Out of memory (OOM killer) - what is causing my memory issue?


Hi,

I would be happy to get some help on this as I cant find the issue.

I try to find the cause why my server gets out of memory every few weeks ans calls the OOM killer. It seems to be that memory usage is stable for about 2 weeks, then going up gradually for 2 weeks. Then there is a big hike resulting in an OOM call.



http://i.stack.imgur.com/PNIO5.jpg



The memory usage just before the hike:

Code:
Wed Jun  3 08:50:01 EDT 2015                                                                                                                   
    COMMAND         %MEM                                                                                                                           
    tor             14.7
    mysqld          11.8                                                                                                                           
    spamd child      5.5                                                                                                                           
    apache2          4.6                                                                                                                           
    spamd child      4.5                                                                                                                           
    apache2          4.4                                                                                                                           
    apache2          4.4                                                                                                                           
    apache2          4.2                                                                                                                           
    apache2          4.2                                                                                                                           
    apache2          3.3                                                                                                                           
    Memory Space Details                                                                                                                           
    Total Memory space : 1250 MB                                                                                                                   
    Used Memory Space : 964 MB                                                                                                                     
    Free Memory : 285 MB                                                                                                                           
    Swap memory Details                                                                                                                            
    Total Swap space : 255 MB                                                                                                                      
    Used Swap Space : 81 MB                                                                                                                        
    Free Swap : 174 MB
Here is the memory usage just before OOM is called.

Code:
Wed Jun  3 09:10:02 EDT 2015                                                                                                                   
    COMMAND         %MEM                                                                                                                           
    tor             13.4
    mysqld          11.2                                                                                                                           
    spamd child      5.2                                                                                                                           
    apache2          3.8                                                                                                                           
    apache2          3.6                                                                                                                           
    apache2          3.3                                                                                                                           
    apache2          2.6                                                                                                                           
    apache2          2.5                                                                                                                           
    apache2          2.5                                                                                                                           
    spamd child      2.4                                                                                                                           
    Memory Space Details                                                                                                                           
    Total Memory space : 1250 MB                                                                                                                   
    Used Memory Space : 873 MB                                                                                                                     
    Free Memory : 376 MB                                                                                                                           
    Swap memory Details                                                                                                                            
    Total Swap space : 255 MB                                                                                                                      
    Used Swap Space : 178 MB                                                                                                                       
    Free Swap : 77 MB


System calling OOM:

Code:
1 Time(s): /usr/sbin/spamd invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
The process TOR is killed.

After a reboot, memory usage drops and system is running well for a few weeks.

Code:
  COMMAND         %MEM                                                                                                                           
    tor             12.0                                                                                                                           
    mysqld           7.8                                                                                                                           
    /usr/sbin/spamd  6.2                                                                                                                           
    spamd child      6.1                                                                                                                           
    spamd child      6.1                                                                                                                           
    apache2          4.4                                                                                                                           
    apache2          2.9                                                                                                                           
    apache2          2.9                                                                                                                           
    apache2          2.5                                                                                                                           
    apache2          2.0                                                                                                                           
    Memory Space Details                                                                                                                           
    Total Memory space : 1250 MB                                                                                                                   
    Used Memory Space : 659 MB                                                                                                                     
    Free Memory : 590 MB                                                                                                                           
    Swap memory Details                                                                                                                            
    Total Swap space : 255 MB                                                                                                                      
    Used Swap Space : 0 MB                                                                                                                         
    Free Swap : 255 MB
Where is the memory jump coming from? Is it just apache that needs a little more memory and I just run out? But if so, why is the memory usage gradually increasing over a period of 2 weeks?

Thanks a lot!
 
Old 06-04-2015, 04:20 PM   #2
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
The problem looks to be with Spam Assassin. I would first suggest to check if you are running perl with cpan. That is, just type in the command "cpan" and see if it responds, you can exit by just typing "exit". If that all checks out then verify he spamd modules are updated. Inside cpan type "install Mail::SpamAssassin::Conf" without the quotes. It will either say it is up to date or start the install. If the install fails then run "reports Mail::SpamAssassin::Conf" to hopefully gleam more information. If it fails or not, run a forced update on spamd. If the cpan install did fail, start asking for further support on that specific issue, but it is beyond what I would want to try to detail here.
 
Old 06-04-2015, 07:05 PM   #3
gombi
LQ Newbie
 
Registered: Jun 2015
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thanks!

That is what I got:

Code:
cpan[3]> install Mail::SpamAssassin::Conf
Mail::SpamAssassin::Conf is up to date (undef).
Code:
# spamassassin -V
SpamAssassin version 3.4.0
  running on Perl version 5.18.2
Isn't spamd using to much memory here? There is no mail activity at the moment.

Code:
COMMAND         %MEM                                                                                                                           
tor             10.3                                                                                                                           
mysqld           9.1                                                                                                                           
spamd child      6.6                                                                                                                           
spamd child      6.4                                                                                                                           
/usr/sbin/spamd  6.2                                                                                                                           
apache2          5.3                                                                                                                           
apache2          4.8                                                                                                                           
apache2          4.6                                                                                                                           
apache2          4.4                                                                                                                           
apache2          4.4

Last edited by gombi; 06-05-2015 at 09:27 AM.
 
Old 06-07-2015, 09:48 PM   #4
GaWdLy
Member
 
Registered: Feb 2013
Location: San Jose, CA
Distribution: RHEL/CentOS/Fedora
Posts: 457

Rep: Reputation: Disabled
Looks like you're trying to d oa fair amount of stuff with not much resource. While it looks like perhaps spamd has a memory leak or just requires more memory as time goes on, this could go away with just a little more resource (RAM).

What do the OOM messages in dmesg or /var/log/messages look like?
 
Old 06-08-2015, 01:46 AM   #5
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 286

Rep: Reputation: 91
The problem is not (necessarily) with spamassassin. Please post the full output of the oom log message. The last line looks like
"kill process <No> (<name>) - score <oom score> - or sacrifice child"

The message you posted "spamd invoked oom killer" means the system was out of memory exactly when spamd tried to reserve a new chunk of memory. This does not mean that spamd is the process having the memory leak. You wrote "the process TOR was killed". From my experience, if exactly one process has a big memory leak, the oom killer is good in identifying and killing the correct process. So maybe tor has the memory leak, but as said, please post the full message.
 
Old 06-08-2015, 09:08 AM   #6
GaWdLy
Member
 
Registered: Feb 2013
Location: San Jose, CA
Distribution: RHEL/CentOS/Fedora
Posts: 457

Rep: Reputation: Disabled
^^ This is exactly where I was going.

The OOM message should tell us what order of memory is lacking, and by how much, and you can also run 'cat /proc/buddyinfo' during one of these events and the following details will help us, as well:

# cat /proc/buddyinfo
Node 0, zone DMA 1 1 1 0 2 1 1 0 1 1 3
Node 0, zone DMA32 5759 6204 1281 334 139 99 26 3 2 4 18
Node 0, zone Normal 80447 90383 12328 1965 852 65 29 21 9 8 25
 
Old 06-08-2015, 09:19 AM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I think you have far too little swap space configured to allow reasonable diagnosis of the real problem.
If you had more swap space, instead of the OOM killer being called, performance would only degrade slowly as the problem expands and the problem would then be much more obvious BEFORE the OOM killer starts destroying evidence.

Last edited by johnsfine; 06-08-2015 at 09:23 AM.
 
Old 06-08-2015, 09:30 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
My favourite OOM analogy - here
 
1 members found this post helpful.
Old 06-08-2015, 11:04 AM   #9
GaWdLy
Member
 
Registered: Feb 2013
Location: San Jose, CA
Distribution: RHEL/CentOS/Fedora
Posts: 457

Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
My favourite OOM analogy - here
Very nice! lol
 
Old 06-08-2015, 11:09 AM   #10
gombi
LQ Newbie
 
Registered: Jun 2015
Posts: 9

Original Poster
Rep: Reputation: Disabled
I agree that spamd caused the OOM killer call but I don't think its the root of the problem. I did run a script every 10 minutes to track the memory usage of the top ten processes. All top ten processes were more or less stable.

I also don't think that low resources are my problem. I normally swapped around 80MB in average and that was very stable and I had no peaks.

I also don't think that the process TOR is the cause as its memory usage is also stable as I can see in my top ten statistic. Its normal that OOM will kill TOR in this case. Its on the top and I prefer to loose this process than apache or mysql.

Here is the kernel output during the OOM call. Maybe someone can see something useful in it: http://pastebin.com/rBvbFcyt

I don't want to increase my swap space for trouble shooting. To get some more info, I run a script now every minute and append memory statistics for all running processes to a file (not only top 10).

I hope that will give more hints when it happens next time.
 
Old 06-08-2015, 11:27 AM   #11
GaWdLy
Member
 
Registered: Feb 2013
Location: San Jose, CA
Distribution: RHEL/CentOS/Fedora
Posts: 457

Rep: Reputation: Disabled
gombi: when you have another incident, it will be good to see /proc/buddyinfo. Sometimes OOM events have nothing to do with RAM, but with some of the zoned memory, instead.
 
Old 06-08-2015, 11:35 AM   #12
gombi
LQ Newbie
 
Registered: Jun 2015
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by GaWdLy View Post
gombi: when you have another incident, it will be good to see /proc/buddyinfo. Sometimes OOM events have nothing to do with RAM, but with some of the zoned memory, instead.
Thanks. Just added to my script.
 
Old 06-08-2015, 01:32 PM   #13
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
Try adding in /etc/sysctl.conf the following line:

vm.min_free_kbytes = 65536

then run: sysctl -p or reboot your machine.
 
Old 06-08-2015, 01:59 PM   #14
gombi
LQ Newbie
 
Registered: Jun 2015
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by robertjinx View Post
Try adding in /etc/sysctl.conf the following line:

vm.min_free_kbytes = 65536

then run: sysctl -p or reboot your machine.
Thanks for the hint.

I have it already set to:

Code:
# sysctl vm.min_free_kbytes                                                                                          
vm.min_free_kbytes = 45056
I don't think that the small difference would change anything.
 
Old 06-08-2015, 02:25 PM   #15
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
Just to add some of my thoughts to the conversation, I somewhat agree with the other posts about proper diagnostics, but at the same time the perl modules needing to be manually updated is a known issue. As such I tend to try to rule out possible known issues to resolve conflicts to see if that fixes the issue before committing time to do further investigation. Habit from work environments that are strict on productivity levels.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding the out-of-memory state and the oom-killer SCBrisbane Linux - Kernel 2 12-21-2012 05:53 AM
OOM killer even though there is memory available Bilb Linux - General 4 12-07-2011 03:03 AM
Out of memory (oom) killer causes system crash? BusyBeeBop Linux - Software 6 06-02-2008 01:42 AM
what process is allocating memory and causing oom-kill? thormk Linux - Server 3 04-22-2008 08:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration