[comp.lang.c] unallocating memory

bobc@attctc.Dallas.TX.US (Bob Calbridge) (01/15/90)

Time for my next question.  I recall that some discussion on this has gone 
before.  I have a program that allocates several areas of heap space.  When
I try to free() the areas I don't end up with the same amount of core space
as I did going into the routine.  Here is the order in which I allocate it.

	Area 1. Medium - about 1K to 5K
	Area 2. Large  - 11 sub-areas of 10K each
	Area 3. Small  - Possibly unlimited number of tiny linked lists

When I free space I free area 3 first although this is hard to pin down since
the area is pretty much intermingled.  I then free area 2 and then 1.  
Since the program can run this portion of code several times at the user's 
option I checked to see if I lost the same amount each time.  I don't.  On the
first run I lose about 114K from my heap.  Each time I run it thereafter I lose
exactly 560 bytes.  I've tried to reconcile this with the size that each
call to malloc() performs (including overhead) and I can't get anything to 
work out to an even integer.  I think I understand how coreleft() works, so
I figure its a matter of one of the latter allocated spaces not getting 
free()ed.  Is that correct?  How can I tell if the space has been freed?
Is there anything other than coreleft() that can help me keep track of what
is and isn't doing the job?

Many thanks.
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=    More stupid questions available on request from                          =
-     bobc@attctc                     Your humble servant (real humble)       -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=