MALLOCCHECK(3-SVR3) RISC/os Reference Manual MALLOCCHECK(3-SVR3)
NAME
malloc, free, realloc, xmalloc, xfree, xrealloc, alloc_new,
alloc_dispose, malloc_status - memory allocator with
checking
DESCRIPTION
The malloccheck library (libmalloccheck.a or -lmalloccheck)
provides replacements for libc's malloc, free, and realloc
functions, and libp's xmalloc, xfree, xrealloc, alloc_new,
and alloc_dispose functions. These functions implement
memory allocation with extensive checking to catch program
bugs. Specifically:
Blocks are surrounded by magic words to check for pro-
grams that write more more than they allocate.
The block is initialized non-zero to catch programs
that assume zero'd data.
Blocks are never reused.
Blocks are overwritten on free to catch programs that
reference them after freeing.
Freeing an already free block is checked.
realloc of freed blocks is flagged, as is
realloc(NULL), to help catch non-portable usage.
Calling malloc_status(0) at the end of the program will
check for problems that haven't come up during the nor-
mal malloc/free checking. Some statistics are printed.
malloc_status(1) does this and additionally prints
blocks that have not been freed (catch your memory
leaks).
Setting malloctrace to an address with dbx(1) allows
you to set a breakpoint to see who allocates that
address.
SEE ALSO
malloc(3)
Printed 11/19/92 Page 1