简体   繁体   English

在 Linux(RedHat) 中,C function malloc_stats() 显示与 /proc/ 不同的值<pid> /stat 常驻 memory 大小</pid>

[英]In Linux(RedHat) , C function malloc_stats() shows different values compared to /proc/<pid>/stat resident memory size

eg For a process running in Redhat linux as per /proc/{pid}/stat's resident pages * page size => 30 GB例如,对于在 Redhat linux 中运行的进程,根据 /proc/{pid}/stat 的常驻页面 * 页面大小 => 30 GB

as per malloc_stats() => 2.5 GB根据malloc_stats() => 2.5 GB

any idea why this happens?知道为什么会这样吗?

Arena 0:
system bytes     =  465162240
in use bytes     =  465037200
Arena 1:
system bytes     =    1003520
in use bytes     =     980656
Arena 2:
system bytes     =    8065024
in use bytes     =    7771728
Arena 3:
system bytes     = 2278395904
in use bytes     = 2276584320
Arena 4:
system bytes     =    1482752
in use bytes     =    1236112
Arena 5:
system bytes     =    1482752
in use bytes     =    1235440
Arena 6:
system bytes     =    1482752
in use bytes     =    1240512
Total (incl. mmap):
system bytes     = 2782,699,520
in use bytes     = 2779710544
max mmap regions =          9
max mmap bytes   =   25624576

malloc_stats is tied to the implementation of malloc in user-land. malloc_stats与用户空间中malloc的实现相关联。

pmap or /proc/self/stat is related to the virtual address space and its perception in kernel land, which changes not only with mmap called by malloc but also with other calls to mmap , including those related to the dynamic linker ( ld.so ) pmap/proc/self/stat与虚拟地址空间及其在 kernel 土地中的感知有关,这不仅会随着malloc调用的mmap发生变化,还会随着对mmap的其他调用而改变,包括与动态ld.so . )

Read a good textbook on operating systems .阅读一本关于操作系统的好教科书 See also https://linuxatemyram.com/ and proc(5) , mmap(2) , execve(2) , malloc(3)另请参见https://linuxatemyram.com/proc(5)mmap(2)execve(2)malloc(3)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM