home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16690 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  1.7 KB

  1. Path: sparky!uunet!ukma!cs.widener.edu!dsinc!netnews.upenn.edu!netnews.cc.lehigh.edu!ns1.cc.lehigh.edu!dsbb
  2. From: dsbb@ns1.cc.lehigh.edu (D. SPENCER BEECHER)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help me track down memory leakage
  5. Message-ID: <1992Nov17.170530.48841@ns1.cc.lehigh.edu>
  6. Date: 17 Nov 92 17:05:30 GMT
  7. Organization: Lehigh University
  8. Lines: 25
  9.  
  10. In article <BxuLIr.DK@rice.edu>, abuhr@owlnet.rice.edu (Aaron M. Buhr) writes:
  11. >
  12. >     I've inherited a very large C program that I am trying to maintain and
  13. >expand, and I've come to the point where I HAVE to find out where the
  14. >program's leaking memory.  The program starts out with about 7MB virtual
  15. >mem usage, 6MB real, and grows over the course of 6-8 hours to around 20MB
  16. >virtual, 10MB real.  The program uses straight malloc() and realloc() calls.
  17. >I don't know where or how to start trying to track this down.  Any help
  18. >would be greatly appreciated.
  19.  
  20. Try investigating "free()".  Do a (word processing) search on the string
  21. "alloc", trace the associated variable use, and free those pointers that
  22. become obsolete.  Do them one at a time if you're unsure about their
  23. individual obsolescence.  A decent compiler should give you a warning if
  24. memory for a necessary variable has been deallocated.  Make sure the
  25. switch for checking this type of thing is on in your compiler.  I imagine
  26. most of the memory suck can be attributed to structure or array allocation.
  27. The first pointers I would check are those which are not used as parameters
  28. by any function.
  29. A word processor with a "search" function, a hard copy, and several colored
  30. markers would probably be invaluable tools.
  31. -- 
  32.                    _ _     _ _     _ _
  33.   -Spence         [O.O]   )x.x(   )O.O(
  34.                     O       O      -*-
  35.