Go to the previous, next section.

Statistics for Storage Allocation with malloc

You can get information about dynamic storage allocation by calling the mstats function. This function and its associated data type are declared in `malloc.h'; they are a GNU extension.

Data Type: struct mstats

This structure type is used to return information about the dynamic storage allocator. It contains the following members:

size_t bytes_total
This is the total size of memory managed by malloc, in bytes.

size_t chunks_used
This is the number of chunks in use. (The storage allocator internally gets chunks of memory from the operating system, and then carves them up to satisfy individual malloc requests; see section Efficiency Considerations for malloc.)

size_t bytes_used
This is the number of bytes in use.

size_t chunks_free
This is the number of chunks which are free -- that is, that have been allocated by the operating system to your program, but which are not now being used.

size_t bytes_free
This is the number of bytes which are free.

Function: struct mstats mstats (void)

This function returns information about the current dynamic memory usage in a structure of type struct mstats.

Go to the previous, next section.