mark@uunet.uu.net (Mark Lawrence) (11/29/88)
I've read the "(3) - memory allocator" man page which talks about the malloc_verify and malloc_debug functions. I note that in the /usr/lib/debug directory, the object for these functions, malloc.o, exists ALONG with object called 'mallocmap.o'. Can anyone fill me in or point me to docuementation about the contents and purpose of mallocmap.o? ...sun!tulsun\ ...uunet!apctrc!drd!mark mlawrence@jarsun1.ZONE1.COM ...rutgers!okstate!romed/ (918)743-3013
dff@morgan.com (Daniel F. Fisher) (12/15/88)
Mark Lawrence's question about /usr/lib/debug/mallocmap.o prompted me to
do a little experiment. The following program
------ cut here ------
#include <stdio.h>
extern char *malloc();
main()
{
char *p, *q;
mallocmap(); fflush(stdout); write(1, "\n", 1);
p = malloc(2000); mallocmap(); fflush(stdout); write(1, "\n", 1);
free(p); mallocmap(); fflush(stdout); write(1, "\n", 1);
p = malloc(4000); mallocmap(); fflush(stdout); write(1, "\n", 1);
q = malloc(2000); mallocmap(); fflush(stdout); write(1, "\n", 1);
free(p); mallocmap(); fflush(stdout); write(1, "\n", 1);
free(q); mallocmap(); fflush(stdout); write(1, "\n", 1);
}
------ cut here ------
compiled with
cc -o experiment experiment.c /usr/lib/debug/mallocmap.o
produces the following output when it is run:
------ cut here ------
204f8: 2004 bytes: busy
20ccc: 6188 bytes: free
224f8: 8196 bytes: busy
204f8: 8192 bytes: free
224f8: 8196 bytes: busy
204f8: 4004 bytes: busy
2149c: 4188 bytes: free
224f8: 8196 bytes: busy
204f8: 4004 bytes: busy
2149c: 2004 bytes: busy
21c70: 2184 bytes: free
224f8: 8196 bytes: busy
204f8: 4004 bytes: free
2149c: 2004 bytes: busy
21c70: 2184 bytes: free
224f8: 8196 bytes: busy
204f8: 8192 bytes: free
224f8: 8196 bytes: busy
------ cut here ------
It appears that mallocmap() is a debugging aid that prints a map of free
and busy memory available for use through malloc() and free().
If only I had known this before. . .
But does it take any arguments or return a value?
Daniel Fisher
Morgan Stanley & Co.
dff@morgan.com