How to measure solaris process memory usage?

Solution 1:

  1. prstat -s rss

    '-s' sorts prstat output by rss column (see man page for other columns). Also try '-a' option for a per user accumulation.

  2. ps -eo pid,pmem,vsz,rss,comm | sort -rnk2 | head

    Top 10 RAM consumers. '-o pmem' displays percentage of resident memory i.e. RAM used by process.

  3. ls -lh /proc/{pid}/as

    Easy way to show total address space (vsz) of a process. Useful in combination with pgrep to accumulate by user, pattern, ... e.g.:

    for pid in `pgrep -U webserver`; do ls -lh /proc/$pid/as; done
    

Solution 2:

Well, after I've read through some man pages I got the following

ps -o vsz -p $PID | tail -1

It is quite straightforward. The format for resident size is rss.

Solution 3:

prstat

Or maybe a dtrace-script?

Solution 4:

I use variation of this output in scripts:

# prstat -Z 1 1 | tail -3
ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU ZONE                        
220       56 1057M  413M   0.3%   1:26:49 0.1% 820f6ce5-7e37-4455-80ab-b28c5de19b43
Total: 56 processes, 169 lwps, load averages: 0.07, 0.06, 0.06