--如何查看單個進程在os層面的內存消耗
AIX:
$ svmon -Pt10 | perl -e 'while(<>){print if($.==2||$&&&!$s++);$.=0 if(/^-+$/)}' ---- -用這個可以看最大的占用內存的10個進程 ------------------------------------------------------------------------------- Pid Command Inuse Pin Pgsp Virtual 64-bit Mthrd 16MB 5111942 svmon 22446 8768 0 22370 Y N N 4391128 ksh 18298 8724 0 18232 N N N 5308430 perl5.8.8 18262 8724 0 18245 N N N AIX:(linux 下也可以使用) $ ps gv PID TTY STAT TIME PGIN SIZE RSS LIM TSIZ TRS %CPU %MEM COMMAND 0 - A 0:51 7 384 384 xx 0 0 0.0 0.0 swapper 1 - A 5:26 105 752 796 32768 31 44 0.0 0.0 /etc/in 131076 - A 5478:05 0 448 448 xx 0 0 25.8 0.0 wait 196614 - A 0:00 0 448 448 xx 0 0 0.0 0.0 sched 262152 - A 0:00 0 512 512 xx 0 0 0.0 0.0 lrud 327690 - A 0:00 0 448 448 xx 0 0 0.0 0.0 vmptacrt 393228 - A 0:00 0 512 512 xx 0 0 0.0 0.0 psmd 458766 - A 0:00 0 896 896 xx 0 0 0.0 0.0 vmmd 524304 - A 0:00 0 448 448 xx 0 0 0.0 0.0 memgrdd 589842 - A 0:00 0 448 448 xx 0 0 0.0 0.0 lsareapr aix 下查看耗費內存最大的前10個進程 $ ps gv|sort -rn +6|head -10 --------------這個也是非常直觀 4128976 - A 1:06 2743 42476 42548 32768 68 72 0.0 4.0 /usr/ja 2687164 - A 0:09 31 9000 9084 32768 60 84 0.0 1.0 /usr/sb 2883710 - A 0:00 37 5696 5904 32768 518 208 0.0 0.0 /usr/sb 3014794 - A 0:01 55 5672 5892 32768 394 220 0.0 0.0 /usr/sb 3145838 - A 0:00 32 5540 5668 32768 164 128 0.0 0.0 /usr/sb 3080322 - A 0:00 24 5472 5528 32768 43 56 0.0 0.0 /usr/sb 4194350 - A 0:05 412 4708 5248 xx 555 540 0.0 0.0 /usr/sb 3407976 - A 0:06 144 4180 5244 32768 1213 1064 0.0 0.0 sendmai 3866866 - A 0:00 129 3792 4400 32768 524 608 0.0 0.0 /usr/sb 2424972 - A 0:00 76 4204 4384 32768 151 180 0.0 0.0 /usr/sb $ aix、linux ---------------建議使用這個 $ ps aux | head -1 ; ps aux | sort -rn +3 | head -10 USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND pconsole 4128976 0.0 4.0 42540 42548 - A Apr 11 1:06 /usr/java5/bin/ root 2687164 0.0 1.0 9056 9084 - A Apr 11 0:09 /usr/sbin/cron root 5636150 0.0 0.0 3928 3940 - A 22:37:25 0:00 telnetd -a root 5046428 0.0 0.0 1628 1652 - A Apr 11 0:00 /usr/sbin/rsct/ root 4849856 0.0 0.0 2624 2140 - A Apr 11 0:00 /usr/sbin/rsct/ root 4784276 0.0 0.0 344 348 - A Apr 11 0:00 /usr/sbin/rpc.l root 4718738 0.0 0.0 1216 1216 - A Apr 11 0:17 rpc.lockd root 4653208 0.0 0.0 108 112 - A Apr 11 0:00 /usr/sbin/uprin root 4587674 0.0 0.0 332 340 - A Apr 11 0:00 /usr/sbin/write root 4456616 0.0 0.0 4064 3904 - A Apr 11 0:25 /usr/bin/topasr $ svmon -uP -t 50|grep -p Pid|grep '^.*[0-9] ' 5112000 svmon 22452 8768 0 22370 Y N N 4391128 ksh 18298 8724 0 18232 N N N 5308462 grep 18163 8724 0 18154 N N N 5767348 grep 18163 8724 0 18154 N N N $ svmon -P -O summary=basic,unit=MB Unit: MB ------------------------------------------------------------------------------- Pid Command Inuse Pin Pgsp Virtual 5112002 svmon 87.7 34.2 0 87.4 4391128 ksh 71.5 34.1 0 71.2 $ $ svmon -U `ps -ef|cut -c1-8|sort -u`-O segment=off -O unit=MB Unit: MB =============================================================================== User Inuse Pin Pgsp Virtual oracle 121.07 34.3 0 120.49 segment=off *** user does not exist *** pconsole-O *** user does not exist *** daemon *** user does not exist *** root *** user does not exist *** UID *** user does not exist ***
查看本欄目更多精彩內容:http://www.bianceng.cn/OS/unix/
作者:csdn博客 lixora