1

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

5 Answers 5

2

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.

2
#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

0

Top does a good job, look for these headers:

VIRT  RES  SHR S %MEM
1
  • 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, 2010 at 13:30
0

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

3
  • 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. May 25, 2010 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 May 25, 2010 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, 2010 at 19:03
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .