c语言 查看进程的内存消耗,如何查看进程实际的内存占用情况详解

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值