[comp.lang.c] C heap garbage collection

cliffhanger@cup.portal.com (Cliff C Heyer) (06/15/90)

Re: MS-DOS MSC 5.1
  I have an object library that fragments memory,
  and I do not have the source to the library or the
  ability to have it fixed.

  I would like to replace the MSC malloc() routines
  with ones that do defragmentation, for example by
  purchasing the MSC 5.1 source and replacing or
  modifying the malloc() routine(s).

Summary of mail:
There is no easy or practical way to do this.

First, to defragment you would have to copy 
data to new memory locations. Once the data is
moved, there may be other pointers in the
program pointing to the old location which would
now be pointing to garbage. You would have to 
modify and recompile the object library.

Second, if you create a table to convert physical
addresses to logical addresses, how are you going
to tell the object library about it? Memory is not
accessed through the malloc() function, it is accessed
via locations in the linked code.  These locations don't
change to your new table just because you install an new
malloc() function. You have to modify and recompile the
object library storage specifications (for example,
add the '*' operator) in order to use any defragmentation
process.