Server Memory Usage VERY high on new linux dedi box - How to find the issue?

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.


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! :)


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?


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.