How can I measure the actual memory usage of an application or process?

后端 未结 30 3129
心在旅途
心在旅途 2020-11-22 03:01

This question is covered here in great detail.

How do you measure the memory usage of an application or process in Linux?

From the blog articl

30条回答
  •  滥情空心
    2020-11-22 03:51

    It is hard to tell for sure, but here are two "close" things that can help.

    $ ps aux
    

    will give you Virtual Size (VSZ)

    You can also get detailed statistics from the /proc file-system by going to /proc/$pid/status.

    The most important is the VmSize, which should be close to what ps aux gives.

    /proc/19420$ cat status
    Name:      firefox
    State:     S (sleeping)
    Tgid:      19420
    Pid:       19420
    PPid:      1
    TracerPid: 0
    Uid:       1000    1000    1000    1000
    Gid:       1000    1000    1000    1000
    FDSize:    256
    Groups:    4 6 20 24 25 29 30 44 46 107 109 115 124 1000
    VmPeak:    222956 kB
    VmSize:    212520 kB
    VmLck:          0 kB
    VmHWM:     127912 kB
    VmRSS:     118768 kB
    VmData:    170180 kB
    VmStk:        228 kB
    VmExe:         28 kB
    VmLib:      35424 kB
    VmPTE:        184 kB
    Threads:   8
    SigQ:      0/16382
    SigPnd:    0000000000000000
    ShdPnd:    0000000000000000
    SigBlk:    0000000000000000
    SigIgn:    0000000020001000
    SigCgt:    000000018000442f
    CapInh:    0000000000000000
    CapPrm:    0000000000000000
    CapEff:    0000000000000000
    Cpus_allowed:    03
    Mems_allowed:    1
    voluntary_ctxt_switches:    63422
    nonvoluntary_ctxt_switches: 7171
    
    

提交回复
热议问题