SagerXiao's Blog

Restart of an old programmer

Linux下查看进程内存使用情况

动态查看一个进程的内存使用

Show process memory usage
1
2
3
top
top -d 1 -p pid [,pid ...] #设置为delay 1s, 默认delay是3s
#shit + m (Sort by memory usage)

静态查看一个进程的内存使用

Static show process memory usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
pmap pid

ps aux|grep process_name

cat /proc/pid/status
Name:   python
State:  S (sleeping)
Tgid:   1813
Pid:    1813
PPid:   1
TracerPid:  0
Uid:    501 501 501 501
Gid:    501 501 501 501
Utrace: 0
FDSize: 64
Groups: 501
VmPeak:   999456 kB
VmSize:   999456 kB
VmLck:         0 kB
VmHWM:     37628 kB
VmRSS:     37628 kB
VmData:   744284 kB
VmStk:       188 kB
VmExe:         4 kB
VmLib:     11548 kB
VmPTE:       532 kB
VmSwap:        0 kB
Threads:    19
SigQ:   0/30515
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000001001007
SigCgt: 0000000180000000
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: ffffffffffffffff
Cpus_allowed:   1
Cpus_allowed_list:  0
Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,\
00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001
Mems_allowed_list:  0
voluntary_ctxt_switches:    84
nonvoluntary_ctxt_switches: 356
#任务虚拟地址空间的大小 VmSize
#应用程序正在使用的物理内存的大小 VmRSS

Comments