Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have recently aquired a dedicated server running CentOS and Plesk for my applications.

These scripts were running on a 1.5GB ram VPS running CentOS and CPanel and worked very well.

Now they are on the new dedicated server the memory has gone down from 14.1 GB ram spare to 9.9GB. I can't see it being my scripts so presume there is something else using all my memory. How can I see what is eating all the resources?

Note: The only difference between these servers (from my point of view) is my crons were being checked every 5 minutes on the old server whereas now they are checked every minute and there are about 60 of them.

This is the information from "free" via SSH - Although, I am not entirely sure what its telling me:

[root@h31-3-244-194 ~]# free
             total       used       free     shared    buffers     cached
Mem:      16426796    9373260    7053536          0     390468    3471680
-/+ buffers/cache:    5511112   10915684
Swap:     18481144          0   18481144

EDIT: I have looked against all my cron processes and they have this: bin/qmail-queue against them. Could qmail be eating the memory?

If I have omitted some required information, please let me know.

Thanks.

share|improve this question
    
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | head –  Jure1873 Jun 9 '11 at 14:40
1  
Relevant: Linux Ate My RAM! –  EEAA Jun 9 '11 at 14:41
    
What does that show? All I get back from that is 9 lines of: /usr/sbin/httpd. What does this mean? –  webnoob Jun 9 '11 at 14:45
    
This has some useful information linuxatemyram.com –  HampusLi Jun 9 '11 at 15:35
add comment

3 Answers

The only number you care about here is this one:

[root@h31-3-244-194 ~]# free
             total       used       free     shared    buffers     cached
Mem:      16426796    9373260    7053536          0     390468    3471680
-/+ buffers/cache:    **5511112**   10915684
Swap:     18481144          0   18481144

This is the amount of memory used by userspace processes for their execution. The kernel will take any extra memory it can get it's hands on for disk caching and other performance reasons, but it will release it as userspace applications require it.

You probably want to run something like top and try to figure out (by using the %MEM field) what is consuming the memory.

Keep in mind that unused memory is wasted memory! :)

share|improve this answer
    
Ok, so although my server is showing 10GB free, its only doing that because the kernal is sucking up lots more for caching and performance? The point is, this server is using about 3.5GB more memory to run my scripts than the VPS did. Does that bit you have highlighted INCLUDE the cached memory that will be released? –  webnoob Jun 9 '11 at 14:44
    
No, that only includes memory used by scripts, processes, etc. So yes, you're correct in saying that this system is consuming ~3.5G more RAM than your VPS. The number above the highlighted one is total physically allocated memory, including cache, buffer pools, etc. –  Kyle Smith Jun 9 '11 at 14:51
    
Is there any way to get a list of all process like top but show memory in MB or KB used? %mem is confusing me. There are lots of 0.5 or 0.1 ... –  webnoob Jun 9 '11 at 15:14
    
racyclist has a command like that listed as another answer. It's unfortunately not as simple as MB/KB used as many processes share libraries that are loaded into memory. Each individual process may appear to use 1 MB but if 950K of that is shared libs, each additional process is only using 50K of new memory. –  Kyle Smith Jun 9 '11 at 16:26
    
I miss Windows .... OK thanks. Will keep digging. –  webnoob Jun 9 '11 at 17:36
show 1 more comment

This command will list all of your processes sorted by memory usage:

ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | more

The first column shows the percentage of memory used by the process. You can use this information to find out which process is using the most.

The real question is . . . Why do you care if you are using more memory when you still have 10GB free?

share|improve this answer
    
+1 This is a good point, there is certainly enough memory. It would be nice for the OP to know why this system is using so much more memory when he believes it's performing the same task. –  Kyle Smith Jun 9 '11 at 14:52
    
Exactly Kyle. I have another 2 VPS's to move over here and at this rate it doesn't look like it will handle it. I was calculating that each VPS migration would use 1.5GB and therefore make a Dedi box cost effective. At this rate, it wont. –  webnoob Jun 9 '11 at 15:04
add comment
up vote 1 down vote accepted

I dug deeper and deeper using this command:

ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",\$x) } print "" }'

which listed all the processes on my server and how much memory they were taking. This then told me that qmail was spamming me with messages. I don't need qmail so have removed it. Server has gone from growing to 100% ram usage to sitting at 6% ... I don't hate linux so much now xD

Thanks to Kyle Smith for the comments and explanation on memory but I need to mark this as the answer because it explains the exact reason my scripts were using more memory on this server.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.