如何测量已分配页表的数量?
How to measure number of allocated page tables?
据我所知,Linux 直到需要时才分配页表(在使用页时按需分配)。
我想检查程序执行期间真正分配了多少页表。
你能告诉我如何测量实际分配的页面数吗?
如果我没理解错的话,您想测量 运行 程序的 table 页数。
您可以使用 RSS
值来计算活动页数 tables:
RSS is the Resident Set Size and is used to show how much memory is
allocated to that process and is in RAM. It does not include memory
that is swapped out. It does include memory from shared libraries as
long as the pages from those libraries are actually in memory. It does
include all stack and heap memory.
使用RSS
分页table大小(默认为4KB)。
例如,我想计算我机器上 tmux 的第 table 页:
$ ps aux | grep tmux
da 21995 0.0 0.0 26416 2768 ? Ss May17 4:16 tmux
RSS 值为 2768,如果我们将其除以 4:692.
但请注意,RSS 也计算共享库。如果我这样做cat /proc/21995/maps
,就会有完整的tmux内存映射列表,其中大部分是glibc共享库。
参考文献:
- What is RSS and VSZ in Linux memory management
- https://manybutfinite.com/post/how-the-kernel-manages-your-memory/
据我所知,Linux 直到需要时才分配页表(在使用页时按需分配)。 我想检查程序执行期间真正分配了多少页表。 你能告诉我如何测量实际分配的页面数吗?
如果我没理解错的话,您想测量 运行 程序的 table 页数。
您可以使用 RSS
值来计算活动页数 tables:
RSS is the Resident Set Size and is used to show how much memory is allocated to that process and is in RAM. It does not include memory that is swapped out. It does include memory from shared libraries as long as the pages from those libraries are actually in memory. It does include all stack and heap memory.
使用RSS
分页table大小(默认为4KB)。
例如,我想计算我机器上 tmux 的第 table 页:
$ ps aux | grep tmux
da 21995 0.0 0.0 26416 2768 ? Ss May17 4:16 tmux
RSS 值为 2768,如果我们将其除以 4:692.
但请注意,RSS 也计算共享库。如果我这样做cat /proc/21995/maps
,就会有完整的tmux内存映射列表,其中大部分是glibc共享库。
参考文献:
- What is RSS and VSZ in Linux memory management
- https://manybutfinite.com/post/how-the-kernel-manages-your-memory/