delorie.com/djgpp/doc/libc/libc_550.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <stdlib.h> struct mallinfo mallinfo(void); |
This function returns information about heap space usage. It is
intended to be used for debugging dynamic memory allocation and tracking
heap usage. The struct mallinfo
structure is defined by
`stdlib.h' as follows:
struct mallinfo { int arena; int ordblks; int smblks; int hblks; int hblkhd; int usmblks; int fsmblks; int uordblks; int fordblks; int keepcost; }; |
whose members are:
arena
sbrk
to
malloc
. Note that this is not the same as sbrk(0)
, since
sbrk
allocates memory in large chunks and then subdivides them
and passes them to malloc
as required. In particular, the result
of sbrk(0)
might be much larger than the arena
member of
struct mallinfo
when the DPMI host allocates memory in
non-contiguous regions (happens on MS-Windows).
ordblks
malloc
.
smblks
malloc
was compiled with the symbol NUMSMALL
defined to a
non-zero value. Doing so activates an optional algorithm which serves
small allocations quickly from a special pool. If this option is
activated, the smblks
member returns the number of free small
blocks (the allocated small blocks are included in the value of
ordblks
).
hblks
hblkhd
usmblks
fsmblks
malloc
was
compiled with NUMSMALL
defined to a non-zero value. In that
case, gives the amount of space in bytes in free small blocks.
uordblks
malloc
to maintain its hidden information in each
allocated block.
fordblks
malloc
in its free
list.
keepcost
The mallinfo
structure filled with information.
ANSI/ISO C | No |
POSIX | No (see note 1) |
Notes:
struct mallinfo info = mallinfo(); printf("Memory in use: %d bytes\n", info.usmblks + info.uordblks); printf("Total heap size: %d bytes\n", info.arena); |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |