How to get the memory taken by each process?
Hi gurus,
I am new to Linux, and here is a dumb question: How can I see the memory taken by each process? Why this question: I have a server (CentOS 5.8), its total memory is 32 GB, and now the used memory is more than 31 GB, so I want to get which process takes most memory. Meantime, if I can see all of the memory taken for every process, that would be best! Till to now, what I did: 1. free -m Code:
[root@ID5xinyong ~]# free -m 2. Code:
top -c, then press: M As the top command output, the %MEM column has been sorted descending, but, I still cannot see the BIG process who takes much memory. So, the dumb question is how to get the process who takes lots of memory. Thanks in advance! |
Quote:
You are using very low ram on that server. :) For example this is one of my boxes: Code:
root@minnie:~# free -m However there is something that i can't understand about your free output, can you post a Code:
# cat /proc/meminfo Code:
vmstat |
Quote:
Hi Celyr, Thanks A Lot for your quick reply! You mean the linux kernel cached lots of RAM? And how can I know how much RAM it cached? Let's say the output of "free -m", the first line: Code:
-------------------------------------------- Thank you very much! |
@liuwenbin168@126.com, in future use [code] tags as @Celyr has - it retains data formatting and makes it easier (and more likely) others will try to help.
As for your problem, RAM gets used for all sorts of things by the kernel and products (like Oracle e.g.). Lets see the output from Code:
cat /proc/meminfo |
Hi Celyr,
Outputs of the commands you adviced: Code:
---------------------------------------------------- Code:
[root@ID5xinyong ~]# vmstat Yes, it looks like my server is doing I/O frequently, but sorry, I am not running any special programs on it. As the value of : swap in/out, data is being swapped in and swapped out quickly, is it also meaning that there is some fishy process? |
Quote:
Thank you, syg00, I will be happy to follow the rule of our forum. |
Much more readable.
It is not a rule - merely common courtesy. If you want people to read your posts, make it easy for them to help you. You have almost 7 Gig reserved for huge pages - which aren't (currently) being used. They can be disabled (at boot), but we can't know if that will affect whatever you are running on that system. Google should help. Personally I'd be inclined to turn it off and see what happens - but it's not my system. |
I also recommend reading http://www.linuxatemyram.com/
|
There is still something not clear to me, ok 7GB reserved for huge_page but i still think there is something wired.
can you do: Code:
# ps aux | sort -b -k 4 | tail Code:
# mount | grep ram Code:
# mount | grep tmp |
Quote:
Yes, my system performance slow down when I configured huge pages for it. I need to learn more knowledge on Huge Pages then I think I will be clear on this problem. Thanks again and have a nice day pls! |
Quote:
Hi Celyr, Here are the prints for these commands: Code:
ps aux | sort -b -k 4 | tail Code:
df -h | grep ram Code:
df -h | grep tmp Code:
[root@ID5xinyong ~]# df -h Is there anything special we can get from these prints? Thanks a lot!! |
Quote:
|
Quote:
Code:
echo number > /proc/sys/vm/nr_hugepages How many processes are you running ? Code:
ps aux | wc -l Code:
mount | grep ramfs |
Quote:
Since I have finished work and I am at home now, I cannot run the commands you provided right now, but I will do it on Monday, and then post the prints here. I do THANKS A MILLION for you teacher's great patience! You're really a nice man, thanks and have a nice weekend please! |
Quote:
Code:
[root@ID5xinyong ~]# echo number > /proc/sys/vm/nr_hugepages Code:
[root@ID5xinyong ~]# ps aux | wc -l "mount | grep ramfs" still returns nothing. Code:
[root@ID5xinyong ~]# mount | grep ramfs |
Hi teachers, thanks for your helps, problem has been changed now.
I'm afraid that I miss-understood the command from Celyr: Code:
echo number > /proc/sys/vm/nr_hugepages Code:
echo 0 > /proc/sys/vm/nr_hugepages Code:
[root@ID5xinyong ~]# free -m I learnt some knowledge from someone's blog, and this is my thinking: the memory taken by huge page cannot be used by other programs(Maybe it just can be used by the program which specifies using HugePage clearly), and it will be in RAM for ever, so Linux OS takes these memory as used. Please teachers correct me if there are mistakes for my understanding. OK, back to the very first question: now, there are still about 24 Gib have been used, I do want to know who takes it. I have read the article provided by @Chris, in the article, it mentioned that the disc cache may take the RAM but these RAM will be released when needed. The example in that article, it takes this for example: Code:
$ free -m Code:
[root@ID5xinyong ~]# free -m Teachers, THANKS IN ADVANCE!! |
Quote:
You may want to have a look I this, it's just a guess but you may be interested http://www-01.ibm.com/support/docvie...id=swg21271236 also it can be useful if you post the rest of ps aux at this point |
Thank you, Celyr, the stuff you provided is helpful.
This is the outputs by issuing ps aux. Code:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND |
All times are GMT -5. The time now is 07:17 PM. |