linux如何linux 查询进程内存占用的内存

Linux下,gcc如何查看程序占用的RAM和rom空间
[问题点数:40分,结帖人han0702]
Linux下,gcc如何查看程序占用的RAM和rom空间
[问题点数:40分,结帖人han0702]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
匿名用户不能发表回复!|博客访问: 1248969
博文数量: 607
注册时间:
认证徽章:
智慧星光高级DBA。
提供北京或河南地区MySQL、Oracle和MongoDB数据库的技术支持(性能调优,故障处理,安装升级,数据恢复等).
微信或QQ:410294 邮箱:cn_
分类: Linux操作系统 13:22:58
1.命令行输入top回车,然后按下大写M按照memory排序,按下大写P按照CPU排序。
2. ps -ef | grep "进程名"
& & ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' | grep 进程名
# ps -ef | grep mongodb | grep -v grep
root & & 18512 & & 1 &8 Feb28 ? & & & &11:25:23 mongod -f mongodb.conf
# ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' | grep 18512 | grep -v grep
18512 mongod & & & & &mongod -f mongodb.conf & & & 8.0 4496 Feb28 root & & &0
pid:进程的ID
vsz:进程占用的虚拟内存
rsz:进程占用的物理内存
3. top -d 1 -p pid
# top -d 1 -p 18512
top - 13:18:41 up 9 days, 19:53, &3 users, &load average: 0.00, 0.00, 0.00
Tasks: & 1 total, & 0 running, & 1 sleeping, & 0 stopped, & 0 zombie
Cpu(s): &0.3%us, &0.3%sy, &0.0%ni, 99.2%id, &0.0%wa, &0.0%hi, &0.3%si, &0.0%st
Mem: & 8191244k total, &7929432k used, & 261812k free, & 122160k buffers
Swap: k total, & &16232k used, k free, &1316248k cached
& PID USER & & &PR &NI &VIRT &RES &SHR S %CPU %MEM & &TIME+ &COMMAND & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &&
18512 root & & &20 & 0 g 5472 S &1.0 76.3 685:26.98 mongod & &&
4. pmap -x pid
# pmap -x 18512
18512: & mongod -f mongodb.conf
Address & & & & & Kbytes & & RSS & Dirty Mode & Mapping
d4c & & & 0 & & & 0 ----- & &[ anon ]
ae4000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
ae5000 & 10240 & & &20 & & &20 rw--- & &[ anon ]
ee6000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
ee7000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
e7000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
e8000 & &1024 & & &20 & & &20 rw--- & &[ anon ]
aae9000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
aaea000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
ea000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
eb000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
beeb000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
beec000 & &1024 & & &24 & & &24 rw--- & &[ anon ]
bfec000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
bfed000 & &1024 & & &20 & & &20 rw--- & &[ anon ]
ed000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
ee000 & 10240 & & &20 & & &20 rw--- & &[ anon ]
caee000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
caef000 & 10240 & & &12 & & &12 rw--- & &[ anon ]
ef000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f0000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
def0000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
def1000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
f1000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f2000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
f2000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f3000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
fcf3000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
fcf4000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
f4000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f5000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
f5000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f6000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
af6000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
af7000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
f7000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f8000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
ef8000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
ef9000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
f9000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
fa000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
fa000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
fb000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
cfb000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
cfc000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
fc000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
fd000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
fd000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
fe000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
afe000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
aff000 & 10240 & & &52 & & &52 rw--- & &[ anon ]
ff000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
0000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
f00000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f01000 & 10240 & & &12 & & &12 rw--- & &[ anon ]
1000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
2000 & 10240 & & &48 & & &48 rw--- & &[ anon ]
2000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
3000 & 10240 & & &28 & & &28 rw--- & &[ anon ]
d03000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
d04000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
4000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
5000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
5000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
6000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
bb06000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
bb07000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
7000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
8000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
cf08000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
cf09000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
9000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
a000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
a000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
b000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
ed0b000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
ed0c000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
c000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
d000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
d000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
e000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
b0e000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
b0f000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
f000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
0000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
f10000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f11000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
1000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
2000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
2000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
3000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
d13000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
d14000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
4000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
5000 & 10240 & & &20 & & &20 rw--- & &[ anon ]
5000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
6000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
b16000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
b17000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
7000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
8000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
f18000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f19000 & 10240 & & &12 & & &12 rw--- & &[ anon ]
9000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
a000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
a000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
b000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
d1b000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
d1c000 & 10240 & & &28 & & &28 rw--- & &[ anon ]
c000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
d000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
d000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
e000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
ab1e000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
ab1f000 & 10240 & & &16 & & &16 rw--- & &[ anon ]
f000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
0000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
bf20000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
bf21000 & 10240 & & &44 & & &44 rw--- & &[ anon ]
1000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
2000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
2000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
3000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
dd23000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
dd24000 & 10240 & & &20 & & &20 rw--- & &[ anon ]
4000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
5000 & 10240 & & &20 & & &20 rw--- & &[ anon ]
5000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
6000 & 10240 & & &44 & & &44 rw--- & &[ anon ]
fb26000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
fb27000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
7000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
8000 & 10240 & & &44 & & &44 rw--- & &[ anon ]
f28000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
f29000 & 10240 & & &44 & & &44 rw--- & &[ anon ]
9000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
a000 & 10240 & & &44 & & &44 rw--- & &[ anon ]
a000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
b000 & 10240 & & &44 & & &44 rw--- & &[ anon ]
d2b000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
d2c000 & 10240 & & &12 & & &12 rw--- & &[ anon ]
c000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
d000 & 10240 & & &12 & & &12 rw--- & &[ anon ]
d000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
e000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
b2e000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
b2f000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
f000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
0000 & 10240 & & & 8 & & & 8 rw--- & &[ anon ]
f30000 & &1576 & & 480 & & & 0 r-x-- &libc-2.12.so
ba000 & &2048 & & & 0 & & & 0 ----- &libc-2.12.so
ba000 & & &16 & & &16 & & &16 r---- &libc-2.12.so
be000 & & & 8 & & & 8 & & & 8 rw--- &libc-2.12.so
c0000 & & &16 & & &12 & & &12 rw--- & &[ anon ]
c4000 & & &92 & & &72 & & & 0 r-x-- &libpthread-2.12.so
db000 & &2048 & & & 0 & & & 0 ----- &libpthread-2.12.so
db000 & & & 4 & & & 4 & & & 4 r---- &libpthread-2.12.so
dc000 & & & 4 & & & 4 & & & 4 rw--- &libpthread-2.12.so
dd000 & & &16 & & & 4 & & & 4 rw--- & &[ anon ]
e1000 & & &88 & & &44 & & & 0 r-x-- &libgcc_s-4.4.7-.so.1
f7000 & &2044 & & & 0 & & & 0 ----- &libgcc_s-4.4.7-.so.1
f6000 & & & 4 & & & 4 & & & 4 rw--- &libgcc_s-4.4.7-.so.1
f7000 & & 524 & & &12 & & & 0 r-x-- &libm-2.12.so
a000 & &2044 & & & 0 & & & 0 ----- &libm-2.12.so
9000 & & & 4 & & & 4 & & & 4 r---- &libm-2.12.so
a000 & & & 4 & & & 4 & & & 4 rw--- &libm-2.12.so
b000 & & & 8 & & & 4 & & & 0 r-x-- &libdl-2.12.so
d000 & &2048 & & & 0 & & & 0 ----- &libdl-2.12.so
b7d000 & & & 4 & & & 4 & & & 4 r---- &libdl-2.12.so
b7e000 & & & 4 & & & 4 & & & 4 rw--- &libdl-2.12.so
b7f000 & & &28 & & & 8 & & & 0 r-x-- &librt-2.12.so
b86000 & &2044 & & & 0 & & & 0 ----- &librt-2.12.so
d85000 & & & 4 & & & 4 & & & 4 r---- &librt-2.12.so
d86000 & & & 4 & & & 4 & & & 4 rw--- &librt-2.12.so
d87000 & & 128 & & &40 & & & 0 r-x-- &ld-2.12.so
e9b000 & & & 4 & & & 0 & & & 0 ----- & &[ anon ]
e9c000 & &1024 & & &24 & & &24 rw--- & &[ anon ]
f9c000 & & &20 & & &20 & & &20 rw--- & &[ anon ]
fa3000 & & & 4 & & & 0 & & & 0 rw--- & &[ anon ]
fa4000 & & & 4 & & & 4 & & & 4 rw--- & &[ anon ]
fa5000 & & & 4 & & & 0 & & & 0 rw--- & &[ anon ]
fa6000 & & & 4 & & & 4 & & & 4 rw--- & &[ anon ]
fa7000 & & & 4 & & & 4 & & & 4 r---- &ld-2.12.so
fa8000 & & & 4 & & & 4 & & & 4 rw--- &ld-2.12.so
fa9000 & & & 4 & & & 4 & & & 4 rw--- & &[ anon ]
faa000 & 43872 & &4808 & & & 0 r-x-- &mongod
a83000 & & 780 & & 780 & & 780 r---- &mongod
b46000 & & 980 & & &40 & & &40 rw--- &mongod
c3b000 & & 444 & & 296 & & 296 rw--- & &[ anon ]
af9e000 & 12288 & 12084 & 12084 rw--- & &[ anon ]
rw--- & &[ anon ]
00007ffd5da06000 & & 136 & & &48 & & &48 rw--- & &[ stack ]
00007ffd5da89000 & & & 4 & & & 4 & & & 0 r-x-- & &[ anon ]
ffffffffff600000 & & & 4 & & & 0 & & & 0 r-x-- & &[ anon ]
---------------- &------ &------ &------
total kB & & & &
& & & & & & & & & & & &&
阅读(2944) | 评论(0) | 转发(1) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。查看LINUX进程内存占用情况
可以直接使用top命令后,查看%MEM的内容。可以选择按进程查看或者按用户查看,如想查看oracle用户的进程内存使用情况的话可以使用如下的命令:
  top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器
  可以直接使用top命令后,查看%MEM的内容。可以选择按进程查看或者按用户查看,如想查看oracle用户的进程内存使用情况的话可以使用如下的命令:
  $ top -u oracle
内容解释:
  PID:进程的ID
  USER:进程所有者
  PR:进程的优先级别,越小越优先被执行
  NInice:值
  VIRT:进程占用的虚拟内存
  RES:进程占用的物理内存
  SHR:进程使用的共享内存
  S:进程的状态。S表示休眠,R表示正在运行,Z表示僵死状态,N表示该进程优先值为负数
  %CPU:进程占用CPU的使用率
  %MEM:进程使用的物理内存和总内存的百分比
  TIME+:该进程启动后占用的总的CPU时间,即占用CPU使用时间的累加值。
  COMMAND:进程启动命令名称
  常用的命令:
  P:按%CPU使用率排行
  T:按MITE+排行
  M:按%MEM排行
  可以根据进程查看进程相关信息占用的内存情况,(进程号可以通过ps查看)如下所示:
  $ pmap -d 14596
  如下例所示:
  $ ps -e -o
'pid,comm,args,pcpu,rsz,vsz,stime,user,uid'&
其中rsz是是实际内存
  $ ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' | grep
oracle |& sort -nrk5
  其中rsz为实际内存,上例实现按内存排序,由大到小
TOP命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况。
TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止该程序为止.比较准确的说,top命令提供了实时的对系统处理器的状态监视.它将显示系统中CPU最“敏感”的任务列表.该命令可以按CPU使用.内存使用和执行时间对任务进行排序;而且该命令的很多特性都可以通过交互式命令或者在个人定制文件中进行设定.
top - 12:38:33 up 50 days,
users,&&load average: 60.58,
61.14, 61.22
Tasks: 203 total,&&60 running,
sleeping,&&&4
stopped,&&&0
Cpu(s)&&: 27.0%us,
73.0%sy,&&0.0%ni,&&0.0%id,&&0.0%wa,&&0.0%hi,&&0.0%si,&&0.0%st
Mem:&&&1939780k
total,&&1375280k
used,&&&564500k
free,&&&109680k
Swap:&&4401800k
total,&&&497456k
used,&&3904344k
free,&&&848712k
USER&&&&&&PR&&NI&&VIRT&&RES&&SHR
%MEM&&&&TIME+&&COMMAND&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&627m
11.0 297:14.76
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&626m
R&&&&6&&7.6&&89:16.62
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&672m
R&&&&0&&7.1&&&1283:08
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&672m
R&&&&0&&6.6&&&1272:30
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&672m
R&&&&0&&6.5&&&1270:03
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&672m
R&&&&8&&6.4&&&1274:13
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&672m
R&&&&0&&6.4&&&1279:37
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&634m
R&&&&0&&5.3&&86:13.90
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&632m&&81m&&74m
R&&&&0&&4.3
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&626m&&72m&&71m
R&&&&0&&3.8&&&6:35.68
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&630m&&68m&&63m
R&&&&8&&3.6
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&630m&&66m&&60m
R&&&&0&&3.5
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&630m&&66m&&60m
R&&&&0&&3.5
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&627m&&63m&&63m
R&&&&0&&3.4&&&1:54.93
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&627m&&59m&&58m
R&&&&8&&3.1&&86:09.64
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&627m&&57m&&56m
R&&&&8&&3.0&&84:38.20
oracle&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
oracle&&&&25&&&0&&626m&&50m&&49m
R&&&&0&&2.7&&84:55.82
oracle&&&&&
一.&&TOP前五行统计信息
统计信息区前五行是系统整体的统计信息。
1.&第一行是任务队列信息
同&uptime&&命令的执行结果:
[root@localhost ~]# uptime
&13:22:30 up 8
users,&&load average: 0.14, 0.38,
其内容如下:
系统运行时间,格式为时:分
当前登录用户数
load average:
0.06, 0.60, 0.48
系统负载,即任务队列的平均长度。&三个数值分别为&&1分钟、5分钟、15分钟前到现在的平均值。
2.&第二、三行为进程和CPU的信息
当有多个CPU时,这些内容可能会超过两行。内容如下:
正在运行的进程数
睡眠的进程数
停止的进程数
僵尸进程数
Cpu(s): 0.3%
用户空间占用CPU百分比
内核空间占用CPU百分比
用户进程空间内改变过优先级的进程占用CPU百分比
空闲CPU百分比
等待输入输出的CPU时间百分比
3.&第四五行为内存信息。
内容如下:
Mem:&191272k total
物理内存总量
使用的物理内存总量
空闲内存总量
用作内核缓存的内存量
Swap:&192772k total
交换区总量
使用的交换区总量
空闲交换区总量
缓冲的交换区总量。&内存中的内容被换出到交换区,而后又被换入到内存,但使用过的交换区尚未被覆盖,&该数值即为这些内容已存在于内存中的交换区的大小。相应的内存再次被换出时可不必再对交换区写入。
二.&&进程信息
进程所有者的用户id
进程所有者的用户名
进程所有者的组名
启动进程的终端名。不是从终端启动的进程则显示为&?
nice值。负值表示高优先级,正值表示低优先级
最后使用的CPU,仅在多CPU环境下有意义
上次更新到现在的CPU时间占用百分比
进程使用的CPU时间总计,单位秒
进程使用的CPU时间总计,单位1/100秒
进程使用的物理内存百分比
进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RES
进程使用的虚拟内存中,被换出的大小,单位kb。
进程使用的、未被换出的物理内存大小,单位kb。RES=CODE+DATA
可执行代码占用的物理内存大小,单位kb
可执行代码以外的部分(数据段+栈)占用的物理内存大小,单位kb
共享内存大小,单位kb
页面错误次数
最后一次写入到现在,被修改过的页面数。
进程状态。
&D=不可中断的睡眠状态
&& &R=运行
&& &S=睡眠
&T=跟踪/停止
&& &Z=僵尸进程
命令名/命令行
若该进程在睡眠,则显示睡眠中的系统函数名
任务标志,参考&sched.h
top&的man&命令解释如下:
&&&&Listed
below are top's available
fields.&&They are always
associated with
the&&letter&&shown,&&regardless&&of
the position you may have established for them with
the&'o' (Order fields) interactive command.Any
field is selectable as the sort field, and you control whether they
are&&sorted
high-to-low&&or&&low-to-high.&&&For&&additional&&information
on sort provisions see&&topic 3c.
TASK Area Commands.
PID&&--&&Process
&&&&&&&The
task's unique process ID, which periodically wraps, though
never&&restarting at zero.
PPID&&--&&Parent
Process Pid
&&&&&&&The
process ID of a task's parent.
RUSER&&--&&Real
&&&&&&&The
real user name of the task's owner.
UID&&--&&User
&&&&&&&The
effective user ID of the task's owner.
USER&&--&&User
&&&&&&&The
effective user name of the task's owner.
GROUP&&--&&Group
&&&&&&&The
effective group name of the task's owner.
TTY&&--&&Controlling
&&&&&&&The&&name
of the controlling
terminal.&&This is usually the
device (serial port, pty, etc.) from which the process was started,
and which it
uses&&for&&input&&oroutput.&&&However,&&a
task need not be associated with a terminal, in which case you'll
see '?' displayed.
PR&&--&&Priority
&&&&&&&The
priority of the task.
NI&&--&&Nice
&&&&&&&The
nice value of the
task.&&&A&&negative&&nice&&value&&means&&higher&&priority,
whereas&&a&&positive
nice value means lower
priority.&&Zero in this field
simply means priority will not be adjusted in determining a task's
dispatchability.
P&&--&&Last
used CPU (SMP)
number representing the last used
processor.&&In a true
SMP&&environment&&this
will likely change frequently since the kernel intentionally uses
weak affinity. Also, the very act of running top may break this
affinity&&and&&cause&&more
processes&&to change CPUs more
often (because of the extra demand for cpu time).
%CPU&&--&&CPU
&&&&&&&The
task's share of the elapsed CPU time since the last screen update,
expressed as a percentage of total CPU
time.&&In a true SMP environment,
if 'Irix mode' is Off, top will operate in 'Solaris mode' where a
task's cpu usage will be divided
by&&the&&total&&number&&of&&CPUs.&&&You
toggle 'Irix/Solaris' modes with the 'I' interactive command.
TIME&&--&&CPU
&&&&&&&Total
CPU time the task has used since it
started.&&When&&'Cumulative&&mode'&&is
On,&&each&&process
is listed with the cpu time that it and its dead children has
used.&&You toggle 'Cumulative
mode' with 'S', which is a command-line option and an interactive
command.&&See the 'S' interactive
command for additional information regarding this mode.
TIME+&&--&&CPU
Time, hundredths
&&&&&&&The
same as 'TIME', but reflecting more granularity through hundredths
sec&&&&&&&&&&ond.
%MEM&&--&&Memory
usage (RES)
task's currently used share of available physical memory.
VIRT&&--&&Virtual
Image (kb)
&&&&&&&The
total amount of virtual memory used by the
task.&&It includes all code, data
and shared libraries plus pages that
have&&been&&swapped&&out.&&(Note:&&you&&can
define&&the STATSIZE=1
environment variable and the VIRT will be calculated from the
/proc/#/state VmSize field.)
&&&&&&&VIRT
= SWAP + RES.
SWAP&&--&&Swapped
&&&&&&&The
swapped out portion of a task's total virtual memory image.
RES&&--&&Resident
&&&&&&&The
non-swapped physical memory a task has used.
&&&&&&&RES
= CODE + DATA.
CODE&&--&&Code
&&&&&&&The
amount of physical memory devoted to
executable&&code,&&also&&known&&as&&the'text
resident set' size or TRS.
DATA&&--&&Data+Stack
&&&&&&&The&&amount
of physical memory devoted to other than executable code, also
known the 'data resident set' size or DRS.
SHR&&--&&Shared
Mem size (kb)
&&&&&&&The
amount of shared memory used by a
task.&&&It&&simply&&reflects&&memory&&that
could be potentially shared with other processes.
nFLT&&--&&Page
Fault count
&&&&&&&The&&number&&of&&major&&page
faults that have occurred for a
task.&&A page fault occurs when a
process attempts to read from or write to a virtual
page&&that&&is
not&&currently&&present&&in&&its
address space.&&A major page
fault is when disk access is involved in making that page
available.
nDRT&&--&&Dirty
Pages count
&&&&&&&The
number of pages that have been modified
since&&they&&were&&last&&written&&to
disk.&&&Dirty&&pages&&must&&be
written to disk before the corresponding physical memory location
can be used for some other virtual page.
S&&--&&Process
&&&&&&&The
status of the task which can be one of:
&&&&&&&&&&&&&'D'
= uninterruptible sleep
&&&&&&&&&&&&&'R'
&&&&&&&&&&&&&'S'
= sleeping
&&&&&&&&&&&&&'T'
= traced or stopped
&&&&&&&&&&&&&'Z'
&&&&&&&Tasks
shown as running should be more properly thought of as 'ready to
run'&&--their&&task_struct
is simply represented on the Linux
run-queue.&&Even without a true
SMP machine, you may see numerous tasks in this
state&&depending&&on&&top's
delay interval and nice value.
Command&&--&&Command
line or Program name
&&&&&&&Display
the command line used to start a task or the name of the associated
program.&&You toggle between
command line and name with 'c', which is
both&&a&&command-line
option and an interactive command.
When&&you've&&chosen&&to
display command lines, processes without a command line (like
kernel threads) will be shown with only the program
name&&in&&parentheses,
as in this
example:&&&&&&&&&&&&&&&&(
mdrecoveryd )
Either&&form&&of&&display
is subject to potential truncation if it's too long to fit in this
field's&&current&&width.&&&That&&width&&depends&&upon&&other&&fields&&selected,
their order and the current screen width.
&&&&&&&Note:
The 'Command' field/column is unique, in that it is not
fixed-width.&&When displayed,
this column will be allocated all remaining screen width
(up&&to&&the
maximum&&512&&characters)&&to&&provide
for the potential growth of program names into command lines.
WCHAN&&--&&Sleeping
in Function
&&&&&&&Depending
on the availability of the kernel link map ('System.map'),
this&&field
will&&show&&the&&name
or the address of the kernel function in which the task is
currently sleeping.&&Running
tasks will display a dash ('-') in this column.
&&&&&&&Note:
By displaying this field, top's own working set will be increased
700Kb.&&&Your&&only&&means
of reducing that overhead will be to stop and
restart&&&&&&&&&&top.
Flags&&--&&Task
&&&&&&&This
column represents the task's current scheduling flags
which&&are&&expressed
in&&hexadecimal&&notation
and with zeros suppressed.&&These
flags are officially documented in
.&&Less formal documentation can
be&&found&&on
the 'Fields select' and 'Order fields' screens.
&&&&&&&默认情况下仅显示比较重要的&&PID、USER、PR、NI、VIRT、RES、SHR、S、%CPU、%MEM、TIME+、COMMAND&&列。
2.1&用快捷键更改显示内容。
(1)更改显示内容通过&f键可以选择显示的内容。
&&&&&&&按&f&键之后会显示列的列表,按&a-z&&即可显示或隐藏对应的列,最后按回车键确定。
(2)按o键可以改变列的显示顺序。
&&&&&&&按小写的&a-z&可以将相应的列向右移动,而大写的&A-Z&&可以将相应的列向左移动。最后按回车键确定。
&&&&&&&按大写的&F&或&O&键,然后按&a-z&可以将进程按照相应的列进行排序。而大写的&&R&键可以将当前的排序倒转。
&&&&&&&设置完按回车返回界面。
三.&&命令使用
详细内容可以参考MAN&帮助文档。这里列举部分内容:
命令格式:
top [-] [d] [p] [q] [c] [C]
[S]&&&&[n]
参数说明:
d:&&指定每两次屏幕信息刷新之间的时间间隔。当然用户可以使用s交互命令来改变之。
p:&&通过指定监控进程ID来仅仅监控某个进程的状态。
q:该选项将使top没有任何延迟的进行刷新。如果调用程序有超级用户权限,那么top将以尽可能高的优先级运行。
S:&指定累计模式
s&:&使top命令在安全模式中运行。这将去除交互命令所带来的潜在危险。
i:&&使top不显示任何闲置或者僵死进程。
c:&&显示整个命令行而不只是显示命令名
在top命令的显示窗口,我们还可以输入以下字母,进行一些交互:
帮助文档如下:
Help for Interactive Commands - procps version 3.2.7
Window 1:Def: Cumulative mode
Off.&&System: Delay 4.0
Secure mode Off.
&&Z,B&&&&&&&Global:
'Z' c 'B' disable/enable bold
&&l,t,m&&&&&Toggle
Summaries: 'l' 't' task/ 'm' mem info
&&1,I&&&&&&&Toggle
SMP view: '1' single/ 'I' Irix/Solaris mode
&&f,o&&&&&.
Fields/Columns: 'f' 'o' change display order
O&&. Select sort field
&&&,&&&&&&.
Move sort field: '&' '&' next col right
&&R,H&&&&&.
Toggle: 'R' normal/ 'H' show threads
&&c,i,S&&&.
Toggle: 'c' cmd name/ 'i' 'S' cumulative time
&&x,y&&&&&.
Toggle highlights: 'x' 'y' running tasks
&&z,b&&&&&.
Toggle: 'z' color/ 'b' bold/reverse (only if 'x' or 'y')
&&u&&&&&&&.
Show specific user only
#&&. Set maximum tasks
&&k,r&&&&&&&Manipulate
tasks: 'k' 'r' renice
update interval
&&W&&&&&&&&&Write
configuration file
&&q&&&&&&&&&Quit
&&&&&&&&&&(
commands shown with '.' require a visible task display window )
Press 'h' or '?' for help with Windows,
h或者?&&:&显示帮助画面,给出一些简短的命令总结说明。
k&&:终止一个进程。系统将提示用户输入需要终止的进程PID,以及需要发送给该进程什么样的信号。一般的终止进程可以使用15信号;如果不能正常结束那就使用信号9强制结束该进程。默认值是信号15。在安全模式中此命令被屏蔽。
i:忽略闲置和僵死进程。这是一个开关式命令。
q:&&退出程序。
r:&&重新安排一个进程的优先级别。系统提示用户输入需要改变的进程PID以及需要设置的进程优先级值。输入一个正值将使优先级降低,反之则可以使该进程拥有更高的优先权。默认值是10。
S:切换到累计模式。
s&:&&改变两次刷新之间的延迟时间。系统将提示用户输入新的时间,单位为s。如果有小数,就换算成ms。输入0值则系统将不断刷新,默认值是5&s。需要注意的是如果设置太小的时间,很可能会引起不断刷新,从而根本来不及看清显示的情况,而且系统负载也会大大增加。
f或者F&:从当前显示中添加或者删除项目。
o或者O&&:改变显示项目的顺序。
l:&切换显示平均负载和启动时间信息。即显示影藏第一行
m:&切换显示内存信息。即显示影藏内存行
t&:&切换显示进程和CPU状态信息。即显示影藏CPU行
c:&&切换显示命令名称和完整命令行。&显示完整的命令。&这个功能很有用。
M&:&根据驻留内存大小进行排序。
P:根据CPU使用百分比大小进行排序。
T:&根据时间/累计时间进行排序。
W:&&将当前设置写入~/.toprc文件中。这是写top配置文件的推荐方法。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。}

我要回帖

更多关于 linux 进程内存占用率 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信