Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: sacleary AT mtu DOT edu (Stephen A. Cleary), djgpp AT delorie DOT com Date: Wed, 19 Mar 1997 17:08:12 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Beginner checking for memory leaks sacleary AT mtu DOT edu (Stephen A. Cleary) wrote: > I am a beginner in C, and I was writing some arbitrary data type > collections (linked list, AVL tree, etc.), and I would like to check my > code for memory leaks. Is there any way you guys know of to do this? > (i.e. all of the free memory functions return the free system memory, > which isn't changed by free()) > > Like is there some library function I'm not aware of that returns the free > memory in the heap? You need the malloc sources (look the v2 directory of the distribution in Simtelnet, you'll find the whole libc sources). In the malloc sources there are a function called _mstat (or something like that), but is conditionally compiled so you must define something like MSTAT (look the file is very clear). Put calls to this routine where you need to see how memory do you have. Then compile and link with it. The rotine dumps the values to stderr. If you have any trouble interpreting the values (or compiling) just ask me. SET --------------- 0 -------------------------------- Salvador Eduardo Tropea (SET). Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013