home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!jaffna.berkeley.edu!lippin
- From: lippin@jaffna.berkeley.edu (The Apathist)
- Newsgroups: comp.programming
- Subject: Re: When should a debugger be used?
- Date: 15 Aug 1992 22:15:49 GMT
- Organization: Authorized Service, Incorporated
- Lines: 53
- Message-ID: <16jvmlINN4j7@agate.berkeley.edu>
- References: <j1ymvg=.pdh@netcom.com> <164c9vINNijk@agate.berkeley.edu> <1992Aug12.233904.11067@thinkage.on.ca>
- Reply-To: lippin@math.berkeley.edu
- NNTP-Posting-Host: jaffna.berkeley.edu
-
- From the tinkling keys of atbowler@thinkage.on.ca (Alan Bowler):
-
- >What features are in your debuggers that allow you to tract memory
- >leaks?
-
- Macintosh debuggers are generally more aware of the heap structure
- than debuggers I've seen on other platforms. This may be because the
- heap structure is documented and easy to look at, or it may be because
- the OS makes heap-related bugs so common.
-
- I'll describe MacsBug here, which is the debugger I generally use for
- memory problems.
-
- For finding memory leaks, two tools are particularly useful. One is
- the "heap total" command, which lists (among other statistics) the
- number and total size of allocated heap blocks. This is good for
- spotting leaks: run through a part of the program a few times, and see
- if the numbers grow in ways you don't expect.
-
- For fixing the leaks, I use an add-on tool called "leaks" (whose
- author I should credit, but I don't have the name handy). When turned
- on, it records block allocations and disposals. It records the call
- chain of the allocations, and groups those with similar call chains
- and sizes. The effect is wonderful -- I run the program for a while,
- and it points out the code that allocates leaky blocks.
-
- For other heap related problems there are features worth pointing out:
-
- It can run a consistency check on the heap structure. This will
- often catch writes to locations just outside a block.
-
- It will (with some difficulty) tell you the stats of a block you're
- interested in. This is particularly useful when you think you may be
- referencing a freed block.
-
- It can be set to break on or record particular system calls (with a
- few limitations). It's a good way to find the spot where you're
- enlarging that memory block, among other problems.
-
- It can use the processor's trace mode to break on a change to a
- particular memory location. This helps find writes through wild
- pointers. On a 68040, the processor caches will allow this to run at
- a respectable speed.
-
- The program being run can issue debugging commands. This helps one
- get a handle on some of the more twisted bugs, particularly those that
- only happen in real time.
-
- --Tom Lippincott
- lippin@math.berkeley.edu
-
- "Come see the violence inherent in the system!"
- --Dennis, "Monty Python and the Holy Grail"
-