home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / programm / 2296 < prev    next >
Encoding:
Text File  |  1992-08-13  |  2.2 KB  |  56 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!cs.utexas.edu!torn!cunews!nrcnet0!bnrgate!scrumpy!samson!morris
  3. From: morris@samson.bnr.ca (Morris Bernstein)
  4. Subject: Re: When should a debugger be used?
  5. Message-ID: <1992Aug13.142140.22853@bnrmtl.bnr.ca>
  6. Sender: news@bnrmtl.bnr.ca (USENET NEWS KJ)
  7. Organization: Bell Northern Research Montreal, Canada.
  8. References: <j1ymvg=.pdh@netcom.com> <164c9vINNijk@agate.berkeley.edu> <1992Aug12.233904.11067@thinkage.on.ca>
  9. Date: Thu, 13 Aug 92 14:21:40 GMT
  10. Lines: 44
  11.  
  12. In article <1992Aug12.233904.11067@thinkage.on.ca> atbowler@thinkage.on.ca (Alan Bowler) writes:
  13. >
  14. >However, I am intrigued by the following statement.
  15. >
  16. >In article <164c9vINNijk@agate.berkeley.edu> lippin@math.berkeley.edu writes:
  17. >>
  18. >>Some bugs (e.g., memory leaks) are very nearly intractable without
  19. >>debugging tools, simply because they show few visible symptoms in
  20. >>ordinary test conditions.
  21. >>
  22. >
  23. >Memory leaks are one of the areas where I have found debuggers to be
  24. >very little use.  I do use it to examine the free memory list, and say
  25. >to myself "this look suspiciously large", but that just tells me there
  26. >MIGHT be a leak.  Finding the actual is has always been more of
  27. >an analysis problem.
  28. >
  29. >What features are in your debuggers that allow you to tract memory
  30. >leaks?  
  31.  
  32.  
  33. This topic was discussed a couple of months ago, when someone asked
  34. how to find a memory leak.  I and several others gave explanations of
  35. varying degrees of clarity.
  36.  
  37. In short, a memory leak can be found using a debugger and auxilliary
  38. tools.  You modify your call to [m]alloc/free to report when memory
  39. operations are performed.  You run a (eg awk) script on the output to
  40. match alloc with free.  You then have a list of memory allocations
  41. that are not freed during your program.
  42.  
  43. You take the list and program your debugger to stop on the nth
  44. occurrence of malloc (there are several ways to do this) where the nth
  45. allocation is not freed.  You then know the context in which the
  46. object is being allocated.  You can usually figure out where it should
  47. be freed.
  48.  
  49.  
  50. Morris
  51. --
  52. Morris Bernstein         phone:    (514) 765-8275
  53. Bell Northern Research Ltd.      fax:    (514) 765-0500
  54. worldnet: bnrmtl!morris@larry.mcrcim.mcgill.edu
  55. "Knowlege is a mind-expanding drug."
  56.