🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #9659

Re: /usr/lib/debug/malloc*

#9659
From: Daniel F. Fisher
Date: Thu, 15 Dec 1988 07:44
65 lines
2105 bytes
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
Technical Details
Message-ID: <8812051443.AA24263@s2.Morgan.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!cornell!uw-beaver!rice!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!cornell!uw-beaver!rice!sun-spots-request
From: dff@morgan.com (Daniel F. Fisher)
Newsgroups: comp.sys.sun
Subject: Re: /usr/lib/debug/malloc*
Message-ID: <8812051443.AA24263@s2.Morgan.COM>
Date: 15 Dec 88 07:44:06 GMT
Sender: usenet@rice.edu
Organization: Rice University, Houston, Texas
Lines: 64
Approved: Sun-Spots@rice.edu
Original-Date: Mon, 5 Dec 88 09:43:39 EST
X-Sun-Spots-Digest: Volume 7, Issue 55, message 8 of 14