我应该查看 VmSize、VmRSS 或某种组合来了解 linux 上的内存统计信息吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8581540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Should i look at VmSize, VmRSS, or some combination for memory stats on linux?
提问by Jason V
I am trying to calculate appropriate sizing data on a linux system for a product and am looking to determine memory usage. The way I am approaching it so far is by running:
我正在尝试在 linux 系统上为产品计算适当的大小数据,并希望确定内存使用情况。到目前为止,我接近它的方式是运行:
cat /proc/<pid>/status
When looking at the output, but I am not sure which figures are relevant. For example:
查看输出时,但我不确定哪些数字是相关的。例如:
VmPeak: 19662464 kB VmSize: 18344416 kB VmLck: 0 kB VmHWM: 5942980 kB VmRSS: 4734832 kB VmData: 2108608 kB VmStk: 120 kB VmExe: 9256 kB VmLib: 304448 kB VmPTE: 10316 kB
I would think i would use VmSize (Virtual Memory right?) or VmRSS (Private Memory right?) or some combination to determine this, but I am not sure. Any pointers on correctly calculating the memory usage of a process in Linux?
我想我会使用 VmSize(正确的虚拟内存?)或 VmRSS(正确的私有内存?)或某种组合来确定这一点,但我不确定。有关正确计算 Linux 中进程的内存使用情况的任何指针?
采纳答案by Wilmer
There are some commands that can help you determine memory usage for a given process:
有一些命令可以帮助您确定给定进程的内存使用情况:
try pmap or pmap -x
尝试pmap或pmap -x
you could also use the old and good topcommand
你也可以使用旧的和好的top命令
vmstatwould be useful too.
vmstat也很有用。
回答by Basile Starynkevitch
A more precise information about the memory map of process of pid 1234 can be given by reading (e.g. with cat
command) the /proc/1234/maps
or /proc/1234/smaps
files. You can also use the pmap
command, e.g. pmap 1234
关于pid 1234进程的内存映射的更精确信息可以通过读取(例如使用cat
命令)/proc/1234/maps
或/proc/1234/smaps
文件来给出。您也可以使用该pmap
命令,例如pmap 1234
回答by Antonio
I think the replys were not answering to your specific question. The key point is that the important value you have to take care is the RAM memory used in the system by your process.
我认为这些答复没有回答您的具体问题。关键是您必须注意的重要值是您的进程在系统中使用的 RAM 内存。
Therefore:
所以:
- In top is shown as residual memory: 'RES' column
- In the '/proc//satus: 'VmRSS' value
- In pmap command: 'RSS' total column value (at the bottom)
- 顶部显示为剩余内存:“RES”列
- 在 '/proc//satus: 'VmRSS' 值
- 在 pmap 命令中:“RSS”总列值(在底部)
Cheers,
干杯,
Antonio
安东尼奥