How can I check actual memory usage each Process?

I can't check actual memory usage in the Redhat 5.5...

The used memory is 14214 Mb of Total 15919 by Free -m command.

I sum the RSS value on PS aux command result and the value is 5428.66Mb.

Yes It's quite different actual usage memory and RSS value.

So I added Shared memory value (4882.22Mb) by ipcs command but It's still quite different even though I added shared memory value to RSS value

Please help me.... now our one of servers reach the memory over 90%.

I can't check which process is taking many memory now..

[root@ ~]# ipcs -m | awk 'BEGIN { TOTAL = 0 }{ TOTAL = TOTAL +$5}END{print TOTAL}'
4999377
[root@ ~]# ps aux | awk 'BEGIN { TOTAL = 0 }{ TOTAL = TOTAL +$6}END{print TOTAL}'
5567792
[root@ ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         15919      15669        250          0        629        823
-/+ buffers/cache:      14215       1704
Swap:        10236       1073       9163

Have a look at the manual page for ps. i haven't got RHEL at the moment, but I think that the -l (lower case L) will give you what you need. It's a long listing and you need the SZ column.

I hope that this helps,
Robin

What's your system? I can't make sense of your 'free' output. That "+/- buffers/cache" line is particularly baffling. If you have a lot of buffers, that's almost the opposite of being out of memory.

I typed PS -l as your guide but I got below result.

[root@ ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0 26124 26085  0  76   0 - 25780 wait   pts/1    00:00:00 su
4 S     0 26125 26124  0  75   0 - 16519 wait   pts/1    00:00:00 bash
4 R     0 26227 26125  0  77   0 - 15877 -      pts/1    00:00:00 ps

the system is Redhat 5.5

This is how you can identify memory growth per process

ps -eo pid,user,rss,vsz,stime,args | cut -c-200 | sort -k3n | tail -50 > mem1

The file mem1 contains the pid and rss and vsz values.
After a couple of minutes do it again but this time to file mem2

ps -eo pid,user,rss,vsz,stime,args | cut -c-200 | sort -k3n | tail -50 > mem2

Now you can compare mem1 and mem2.
A helpful command is

awk 'BEGIN {print "growth  pid  user  rss  vsz  stime  args"} NR==FNR {s[$1]=$3+$4; next} (($1 in s) && $3+$4>s[$1]) {print "+"$3+$4-s[$1],$0}' mem1 mem2
1 Like

There is no command that gives the �actual memory usage of a process� because there is no such thing as the actual memory usage of a process.

Each memory page of a process could be (among other distinctions):

1.Transient storage used by that process alone.
2.Shared with other processes using a variety of mechanisms.
3.Backed up by a disk file.
4.In physical memory or swap.

I think the �dirty� figure adds up everything that is in RAM (not swap) and not backed by a file. This includes both shared and non-shared memory (though in most cases other than forking servers, shared memory consists of memory-mapped files only).

The information displayed by pmap comes from /proc/PID/maps and /proc/PID/smaps. That is the real memory usage of the process � it can't be summarized by a single number.

Christian
Network Admin
Free SharePoint Hosting