|
|
 | | From: | Ole Andre Karlson | | Subject: | MallocDebug/ObjectAlloc | | Date: | Wed, 29 Dec 2004 15:17:50 +0100 |
|
|
 | Hi,
MallocDebug and ObjectAlloc are giving me conflicting reports :( According to MallocDebug my application doesn't leak while ObjectAlloc tells me I'm loosing a bunch of GeneralBlocks once every minute or so..
Who should I trust?
thanks Ole Andre Karlson oleaka@ifi.uio.no http://heim.ifi.uio.no/~oleaka
|
|
 | | From: | Michael Ash | | Subject: | Re: MallocDebug/ObjectAlloc | | Date: | Wed, 29 Dec 2004 16:41:43 -0600 |
|
|
 | Ole Andre Karlson wrote: > Hi, > > MallocDebug and ObjectAlloc are giving me conflicting reports :( > According to MallocDebug my application doesn't leak while ObjectAlloc > tells me I'm loosing a bunch of GeneralBlocks once every minute or so.. > > Who should I trust?
MallocDebug and ObjectAlloc don't do the same kind of thing.
MallocDebug checks for unreachable objects. This is an object that has no possible reference to it anywhere in the application. It is basically a garbage collector without the collector part.
ObjectAlloc works by having you perform an action that shouldn't increase the total number of objects allocated, and then seeing if the number of objects allocated actually goes up or not.
It's entirely possible for ObjectAlloc to report a "leak" that isn't really a leak. If you're building a list of objects and adding to that list, ObjectAlloc will show a "leak" because the number of objects isn't constant, but it's not a real leak.
It's also possible to write a leak that MallocDebug won't find, because you still have a reference to the object. For example, if you have a global mutable array and you add an object to that array, but never use the object again or remove it from the array, this is a legitimate memory leak, but MallocDebug won't find it because it's still referenced.
As far as who you should trust, I personally believe that I get the best results using 'leaks' from the command line. In theory it should show pretty much the same results as MallocDebug, but it seems to work a lot better.
|
|
|