linux - massif 报告的堆使用量比 VmRss 少得多,这可能是什么问题?

标签 linux memory-leaks valgrind memory-fragmentation massif

地 block 输出:

time=3220706
mem_heap_B=393242041
mem_heap_extra_B=73912175
mem_stacks_B=93616
heap_tree=peak

进程在 VmRss 中显示 1.2GB,那么巨大的差异来自哪里? (我看到Rss不断地长大)。

最佳答案

根据 http://cs.swan.ac.uk/~csoliver/ok-sat-library/internet_html/doc/doc/Valgrind/3.8.1/html/ms-manual.html

Heap allocation functions such as malloc are built on top of these system calls. For example, when needed, an allocator will typically call mmap to allocate a large chunk of memory, and then hand over pieces of that memory chunk to the client program in response to calls to malloc et al. Massif directly measures only these higher-level malloc et al calls, not the lower-level system calls.

无法保证基于 massif 输出的 RSS 大小。使用 --pages-as-heap=yes 选项,您也许能够估计 VIRT 大小,但这包括映射到内存中的所有内容,而不必驻留在 RAM 中。

您可能想尝试使用 alloc-fn 选项,通过手动指定所有“自定义”内存分配函数,它可以使您更接近于估计实际内存使用情况。

关于linux - massif 报告的堆使用量比 VmRss 少得多,这可能是什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46129276/

相关文章:

c++ - 恐惧引起的泄漏

android - ListView 的内容占用大量内存

c++ - VALGRIND:如何将 valgrind 用于 ".so"库?

c++ - C++程序什么都不做,但是Valgrind显示内存分配

c++ - 在C++中捕获shell脚本退出状态

python - Windows xp 和 Linux 中的 Telnet 性能

linux - Shell 脚本 - 检查参数上的数字是否唯一

excel - 如何引用父类终止一个类?

linux - 文件计数程序是 shell 不太工作

linux - Valgrind 未处理的指令字节 : : 0x8F 0xEA 0xF8 0x10 0xC9 0x3 0x1D 0x0