简体   繁体   中英

Checking heap being used by a running process on Solaris 10

How can I check heap being used by a running process on Solaris 10? pmap is providing info, but I would like to see the heap usage, do I have to do like this?

pmap | grep [heap]

If we would like to know programmatically from within the program, we may use the following command:

struct mallinfo mallinfo(void);

The mallinfo() function returns a copy of a structure containing information about memory allocations performed by malloc and related functions. This structure is defined as follows:

       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) */
       };

Will this be helpful to know how much memory we have already allocated (total memory allocated - total memory deallocated as the net memory allocated)?

研究<procfs.h>可用的功能可能是最好的选择。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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