如何檢視程序的實際的記憶體佔用
阿新 • • 發佈:2019-02-20
top命令可以檢視程序記憶體的使用,但是不夠詳細。還有一些命令可以進行更加詳細的檢視。
[root@localhost ~]# cat /proc/5606/status
Name: switch4
State: S (sleeping)
Tgid: 5606
Pid: 5606
PPid: 1
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
Utrace: 0
FDSize: 32
Groups: 0 1 2 3 4 6 10
VmPeak: 85328 kB
VmSize: 84308 kB——程序佔用的虛擬記憶體大小。
VmLck: 0 kB
VmHWM: 46368 kB
VmRSS: 46360 kB——佔用的實體記憶體。
VmData: 76512 kB——data段記憶體大小(BSS,data)
VmStk: 88 kB——棧大小。
VmExe: 312 kB——程式碼段大小。
VmLib: 6868 kB——庫大小
VmPTE: 148 kB
VmSwap: 0 kB
Threads: 4
SigQ: 1/31237
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000005
SigCgt: 0000000180005202
CapInh: 0000000000000000
CapPrm: ffffffffffffffff
CapEff: ffffffffffffffff
CapBnd: ffffffffffffffff
Cpus_allowed: ff
Cpus_allowed_list: 0-7
Mems_allowed: 1
Mems_allowed_list: 0
voluntary_ctxt_switches: 116683469
nonvoluntary_ctxt_switches: 301173
[root@localhost ~]# cat /proc/5627/smaps
00110000-00112000 r-xp 00000000 08:02 652817 /home/mic_lib_2012-04-21-03-16-32/libdb.so
Size: 8 kB
Rss: 8 kB
Pss: 1 kB
Shared_Clean: 8 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 8 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
00112000-00113000 rw-p 00001000 08:02 652817 /home/mic_lib_2012-04-21-03-16-32/libdb.so
Size: 4 kB
Rss: 4 kB
Pss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 4 kB
Referenced: 4 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
08048000-080a2000 r-xp 00000000 08:02 1044485 /home/execute_2012-04-21-03-16-32/mrfc
Size: 360 kB——虛擬記憶體
Rss: 156 kB——實體記憶體
Pss: 156 kB
Shared_Clean: 0 kB——共享部分,動態連結庫
Shared_Dirty: 0 kB
Private_Clean: 156 kB——私有部分。
Private_Dirty: 0 kB
Referenced: 156 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
09f43000-09f87000 rw-p 00000000 00:00 0 [heap]——堆的記憶體
Size: 272 kB
Rss: 184 kB
Pss: 184 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 184 kB
Referenced: 184 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
b6cfc000-b6cfd000 ---p 00000000 00:00 0
Size: 4 kB
Rss: 0 kB
Pss: 0 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
b6cfd000-b7703000 rw-p 00000000 00:00 0
Size: 10264 kB
Rss: 28 kB
Pss: 28 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 28 kB
Referenced: 28 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
b7714000-b7716000 rw-p 00000000 00:00 0
Size: 8 kB
Rss: 8 kB
Pss: 8 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 8 kB
Referenced: 8 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
bfed4000-bfee9000 rw-p 00000000 00:00 0 [stack]——棧的記憶體。
Size: 88 kB
Rss: 44 kB
Pss: 44 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 44 kB
Referenced: 44 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
[root@localhost ~]# cat /proc/5606/status
Name: switch4
State: S (sleeping)
Tgid: 5606
Pid: 5606
PPid: 1
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
Utrace: 0
FDSize: 32
Groups: 0 1 2 3 4 6 10
VmPeak: 85328 kB
VmSize: 84308 kB——程序佔用的虛擬記憶體大小。
VmLck: 0 kB
VmHWM: 46368 kB
VmRSS: 46360 kB——佔用的實體記憶體。
VmData: 76512 kB——data段記憶體大小(BSS,data)
VmStk: 88 kB——棧大小。
VmExe: 312 kB——程式碼段大小。
VmLib: 6868 kB——庫大小
VmPTE: 148 kB
VmSwap: 0 kB
Threads: 4
SigQ: 1/31237
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000005
SigCgt: 0000000180005202
CapInh: 0000000000000000
CapPrm: ffffffffffffffff
CapEff: ffffffffffffffff
CapBnd: ffffffffffffffff
Cpus_allowed: ff
Cpus_allowed_list: 0-7
Mems_allowed: 1
Mems_allowed_list: 0
voluntary_ctxt_switches: 116683469
nonvoluntary_ctxt_switches: 301173
[root@localhost ~]# cat /proc/5627/smaps
00110000-00112000 r-xp 00000000 08:02 652817 /home/mic_lib_2012-04-21-03-16-32/libdb.so
Size: 8 kB
Rss: 8 kB
Pss: 1 kB
Shared_Clean: 8 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 8 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
00112000-00113000 rw-p 00001000 08:02 652817 /home/mic_lib_2012-04-21-03-16-32/libdb.so
Size: 4 kB
Rss: 4 kB
Pss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 4 kB
Referenced: 4 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
08048000-080a2000 r-xp 00000000 08:02 1044485 /home/execute_2012-04-21-03-16-32/mrfc
Size: 360 kB——虛擬記憶體
Rss: 156 kB——實體記憶體
Pss: 156 kB
Shared_Clean: 0 kB——共享部分,動態連結庫
Shared_Dirty: 0 kB
Private_Clean: 156 kB——私有部分。
Private_Dirty: 0 kB
Referenced: 156 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
09f43000-09f87000 rw-p 00000000 00:00 0 [heap]——堆的記憶體
Size: 272 kB
Rss: 184 kB
Pss: 184 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 184 kB
Referenced: 184 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
b6cfc000-b6cfd000 ---p 00000000 00:00 0
Size: 4 kB
Rss: 0 kB
Pss: 0 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
b6cfd000-b7703000 rw-p 00000000 00:00 0
Size: 10264 kB
Rss: 28 kB
Pss: 28 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 28 kB
Referenced: 28 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
b7714000-b7716000 rw-p 00000000 00:00 0
Size: 8 kB
Rss: 8 kB
Pss: 8 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 8 kB
Referenced: 8 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
bfed4000-bfee9000 rw-p 00000000 00:00 0 [stack]——棧的記憶體。
Size: 88 kB
Rss: 44 kB
Pss: 44 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 44 kB
Referenced: 44 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB