Search the web
Sign In
New User? Sign Up
dmalloc · Debug Malloc Library (dmalloc) Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Dmalloc Memory leak hunt. Can you tell me if I understand this righ   Message List  
Reply | Forward Message #104 of 529 |
I've got the dmalloc online docs and I'm trying to understand how to
find a memory leak. Here is my situation.

I'm using a library called Swarm and I've compiled it with dmalloc
support. The dmalloc logfile correctly identifies the sources of memory
leaks as a file called Zone.m in the Swarm library. Zone.m has to an
Objective-C method called "allocBlock:" which is a 'wrapper' around
malloc. I call allocBlock: in several parts of my code, and so the
unfreed memory emanates from Zone.m. Since I make many different calls
in different files on that method in Zone.m, I really need to do the
followup search for memory leaks.

In the dmalloc guide section "Tracking down Non-Freed Memory" I get the
idea to do this. First, My dmalloc is compiled with the default
STORE_SEEN_COUNT on, so my logfile looks like this:

940349216: 302075: not freed: '0x8582188|s679' (32 bytes) from
'Zone.m:33'
940349216: 302075: not freed: '0x85821c8|s1' (32 bytes) from 'Zone.m:33'
940349216: 302075: not freed: '0x8582208|s1' (32 bytes) from 'Zone.m:33'
940349216: 302075: not freed: '0x8582248|s167' (32 bytes) from
'ra=0x4036ecb7'
940349216: 302075: not freed: '0x8582288|s1279' (32 bytes) from
'ra=0x4036ecb7'
940349216: 302075: not freed: '0x85822c8|s11' (32 bytes) from
'Zone.m:33'
940349216: 302075: not freed: '0x8582308|s85' (32 bytes) from
'Zone.m:33'

So I've got some unidentified leaks and some in Zone.m. In fact, I seem
to have thousands of them.

So I try to follow dmalloc the guide and start a new bash and use the
command:

dmalloc -l logfile -i 100 low -a 0x8582188:679

(It seems like I have to start bash again each time, or else the dmalloc
error log does not get created...)

Then I ran the program under gdb with "break dmalloc_error".

So when I hit this break point, I do "bt" to see where the program was
when that particular memory got allocated.

Now, the questions:
1. Am I supposed to repeat this procedure for every leak in the logfile?
--run the program, look at the log--rerun the dmalloc command in the
shell, then run the program under the debugger. I don't mean to seem
lazy, but is there no more easier way?

2. I wonder if dmalloc might give false warnings about memory allocated
in one file that is freed in another. For example, if a function
returns a pointer to some memory allocation, which is used in another
file, and then freed there. It seems like some of the things that I
think I'm freeing are showing up in the logfile as unfreed. I admit
readily my code may be wrong, but I'm just asking to make sure dmalloc
handles this possibility.

Thanks in advance
--
Paul E. Johnson email: pauljohn@...
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700



Tue Oct 19, 1999 7:39 pm

pauljohn@...
Send Email Send Email

Forward
Message #104 of 529 |
Expand Messages Author Sort by Date

I've got the dmalloc online docs and I'm trying to understand how to find a memory leak. Here is my situation. I'm using a library called Swarm and I've...
Paul Johnson
pauljohn@...
Send Email
Oct 19, 1999
7:39 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help