What if I don't free() all my dynamically allocated memory?

David Geary dmg at ssc-vax.UUCP
Thu Apr 6 10:40:43 AEST 1989


  I'm writing some code where I use some home-grown functions to
  create, manipulate and destroy a tree of "generic" structures.
  (Each object in the tree is dynamically allocated using malloc())

  The last thing I do in the program is to free every object in
  the tree.

  After running prof on the executable, I found that almost half
  my time was spent in _free!  

  If I don't bother to free all of the memory I've dynamically
  allocated in the tree structure, my program runs considerably
  faster.

  Anyway, I'm wondering if it's ok for me to just leave the freeing
  out altogether.  Unix will free all of my resources for me anyway
  right?  Is there any problem with doing this?

  Of course, I realize this would cause serious problems if ever
  ported to a lowly PC, but I don't care ;-)

  Thanks for the help,

  David
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ David Geary, Boeing Aerospace, Seattle                 ~ 
~ "I wish I lived where it *only* rains 364 days a year" ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the Comp.lang.c mailing list