如何在Solaris 10上检查正在运行的进程使用的堆? pmap提供信息,但我想看看堆的用法,我是否必须这样做?
pmap | grep [heap]
如果我们想从程序中以编程方式知道,我们可以使用以下命令:
struct mallinfo mallinfo(void);
mallinfo()函数返回一个结构的副本,该结构包含有关malloc和相关函数执行的内存分配的信息。该结构定义如下:
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) */
};
这有助于了解我们已经分配了多少内存(分配的总内存 - 已分配的内存总量作为分配的内存)?
答案 0 :(得分:1)
调查<procfs.h>
提供的功能可能是
你最好的选择。