I have a mysql server running debian with 2GO of RAM. I would like to know the amount of memory used by each process.

I thought ps -aux was the command and options for it. But I only see 90 MO used by several processes and free -m tells me that 1400 MO are used.

Is there a way to have a better view with the processes and the memory used by them ?

srv-datax:~# free -m
             total       used       free     shared    buffers     cached
Mem:          2015       1476        539          0          0         70
-/+ buffers/cache:       1405        609
Swap:          486          0        486
link|improve this question
feedback

5 Answers

#top

is a good option

#top -H

lets you monitor all Threads

#top -U root

this kind of using '-U' switch lets you monitor user-specific listing

link|improve this answer
feedback

You should post your free output so we know you are reading is correctly. Memory usage on Linux for a process is hard to nail down specifically, if you really want to get into the details and have a recent kernel, check cat /proc/<pid>/smaps.

link|improve this answer
feedback

Top does a good job, look for these headers:

VIRT  RES  SHR S %MEM
link|improve this answer
srv-datax:~# free -m total used free shared buffers cached Mem: 2015 1476 539 0 0 70 -/+ buffers/cache: 1405 609 Swap: 486 0 486 – tuxsmouf May 25 '10 at 13:30
feedback

Another option along the same lines as what AbhishekKr suggested: ps aux will give you a breakdown of the memory used by every process on the system.

VSZ => Virtual Size (physical RAM+swap used), RSS => Resident Size (physical RAM only).
The %MEM column reflects the % of physical RAM used if memory serves, I'm sure someone will correct me if I'm wrong :)

link|improve this answer
1  
The problem is those are kind of messed up, they don't properly account for shared memory, so if you have a bunch of instances of a program, it will show that memory over and over again. The end result being that summed RSS overestimates memory. – Kyle Brandt May 25 '10 at 18:24
For example: ps -A -o rss,cmd | grep oracle | awk '{print $1}' | (tr '\n' '+'; echo 0) | bc returns 12733324, where as free -buffers/cache is 1741736 – Kyle Brandt May 25 '10 at 18:28
That's true: ps includes shared memory in RSZ. If you're summing up the data this can lead to over-counting, but it's still a good indicator of rough size for a single process if you don't mind that fuzz. If you want to exclude shared pages top's output is probably better as it lists shared memory separately. – voretaq7 May 25 '10 at 19:03
feedback

Adding to what Kyle Brandt suggested, you could use the Tool pmap which nicely summarizes the information found in /proc/<pid>/smap. If you use the -d option, it will show you how much memory is mapped, shared and set private. This, IMHO, provides a good view.

I can also suggest reading this interesting article about memory usage.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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