简体   繁体   English

mallinfo 不显示 mmap 分配的信息

[英]mallinfo doesn't show mmap allocation's information

In mallinfo structure there are two fields hblks and hblkhd .在 mallinfo 结构中有两个字段hblkshblkhd The man documentation says that they are responsible for the number of blocks allocated by mmap and the total number of bytes. man文档说他们负责mmap分配的块数和总字节数。 But when I run next code但是当我运行下一个代码时

void * ptr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
*(int *) ptr = 10;

Fields hblks and hblkhd are also zero.字段hblkshblkhd也为零。 While the total number of free bytes in the blocks decreases.而块中的空闲字节总数减少。 Could you please explain why this behavior is observed?您能解释一下为什么会出现这种行为吗?

I also tried to allocate all free space and use mmap after it.我还尝试分配所有可用空间并在其后使用 mmap。 But in this situation fields also equal to zero但在这种情况下,字段也等于零

Compiler: gcc 9.4.0 OS: Ubuntu 20.04.1编译器:gcc 9.4.0 操作系统:Ubuntu 20.04.1

I did some experiments and they led me to the conclusion that this field is filled only when mmap occurred when calling malloc .我做了一些实验,它们让我得出结论,只有当调用malloc时发生mmap时,这个字段才会被填充。 A normal mmap call doesn't show up in this statistic, which is logical, because this is a system call, and the statistic is collected in user-space正常的mmap调用不会显示在此统计信息中,这是合乎逻辑的,因为这是系统调用,并且统计信息是在用户空间中收集的

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

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