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