Reputation: 7128
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)?
Upvotes: 0
Views: 292
Reputation: 2576
Investigating the functions available from <procfs.h>
is probably
your best bet.
Upvotes: 1