linux – 支持64位的mallinfo替代品?
发布时间:2020-12-14 01:44:43 所属栏目:Linux 来源:网络整理
导读:在 Linux上,我们有一个名为 mallinfo的(GNU C库)函数,它为您提供了一些与内存分配相关的数字: struct mallinfo { int arena; /* Non-mmapped space allocated (bytes) */ int ordblks; /* Number of free chunks */ int smblks; /* Number of free fastbin
在
Linux上,我们有一个名为
mallinfo的(GNU C库)函数,它为您提供了一些与内存分配相关的数字:
struct mallinfo { int arena; /* Non-mmapped space allocated (bytes) */ int ordblks; /* Number of free chunks */ int smblks; /* Number of free fastbin blocks */ int hblks; /* Number of mmapped regions */ int hblkhd; /* Space allocated in mmapped regions (bytes) */ int usmblks; /* Maximum total allocated space (bytes) */ int fsmblks; /* Space in freed fastbin blocks (bytes) */ int uordblks; /* Total allocated space (bytes) */ int fordblks; /* Total free space (bytes) */ int keepcost; /* Top-most,releasable space (bytes) */ }; 奇怪的是,这些值通常是32位整数(!);好吧,这真的不会做,特别是对于以字节数给出的值(例如fordblks). 我猜这是以某种方式被弃用,并且其他一些设施可用于获取相同的信息.什么是替代设施? 解决方法
使用malloc_info().你需要解析它的xml输出.
从 malloc_info man page:
malloc_info的源代码是例如 例如.在我的系统上(glibc版本2.26)malloc_info(0,stdout)打印出以下内容: <malloc version="1"> <heap nr="0"> <sizes> </sizes> <total type="fast" count="0" size="0"/> <total type="rest" count="0" size="0"/> <system type="current" size="135168"/> <system type="max" size="135168"/> <aspace type="total" size="135168"/> <aspace type="mprotect" size="135168"/> </heap> <total type="fast" count="0" size="0"/> <total type="rest" count="0" size="0"/> <total type="mmap" count="0" size="0"/> <system type="current" size="135168"/> <system type="max" size="135168"/> <aspace type="total" size="135168"/> <aspace type="mprotect" size="135168"/> </malloc> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |