如何在没有写时复制页面的情况下测量内存?

Eug*_*kov 8 linux memory

如何在不重复计算共享页面和写时复制页面的情况下测量一组(分叉)进程占用的总 RSS 内存?

Eug*_*kov 4

我最终为此编写了自己的实用程序:https ://gist.github.com/Eugeny/04ccfe8accf4bc74b0ca

\n\n

我针对init(pid 1)运行它进行测试,报告的总数大致等于物理内存使用量(根据 htop),所以我猜它有点正确。

\n\n

使用示例:

\n\n
~ \xc2\xbb pstree -ap 15897\nzsh,15897\n  \xe2\x94\x94\xe2\x94\x80sudo,9783 make rundev\n      \xe2\x94\x94\xe2\x94\x80make,9784 rundev\n          \xe2\x94\x94\xe2\x94\x80sh,9785 -c cd ajenti-panel && ./ajenti-panel -v --autologin --plugins ../plugins --dev\n              \xe2\x94\x94\xe2\x94\x80python ./ajenti,9786\n                  \xe2\x94\x9c\xe2\x94\x80./ajenti-panel ,9834                              \n                  \xe2\x94\x9c\xe2\x94\x80./ajenti-panel ,9795                     \n                  \xe2\x94\x94\xe2\x94\x80{python ./ajenti},9796\n\n~ \xc2\xbb sudo ./memuse.py 15897\nPID                 Commandline                          Frames (+unique)           VMEM\n - 15897            (/usr/bin/zsh                  ):      1776  +1776           7104 KB\n  -  9783           (sudo make rundev              ):       608  +408            2432 KB\n   -  9784          (make rundev                   ):       261  +98             1044 KB\n    -  9785         (/bin/sh -c cd ajenti-panel && ):       166  +48              664 KB\n     -  9786        (python ./ajenti-panel -v --aut):      9279  +8977          37116 KB\n      -  9795       (./ajenti-panel worker [restric):      7637  +1334          30548 KB\n      -  9834       (./ajenti-panel worker [session):      8972  +2639          35888 KB\n----------------------------------------------------------------------------------------\nTOTAL:                                                    15280                 61120 KB\n
Run Code Online (Sandbox Code Playgroud)\n