Re: Leak Hunting and Object Alloc
Re: Leak Hunting and Object Alloc
- Subject: Re: Leak Hunting and Object Alloc
- From: Matt Neuburg <email@hidden>
- Date: Fri, 24 Nov 2006 08:09:33 -0800
- Thread-topic: Leak Hunting and Object Alloc
On Thu, 23 Nov 2006 06:33:59 -0800, Skip Haughay <email@hidden> said:
>This is terribly frustrating.
>
>I am attempting too chase down some leaks in my framework. I am having a
difficult time of it. I have a leak that is being reported in the leaks tool:
>
>Leak: 0x003cf680 size=48 instance of 'com_apple_ist_ds2_pub_common_Name'
> 0x053040ac 0x00000000 0x00000000 0x00000000 .0@.............
> 0x00000000 0x00000000 0x00000000 0x00000000 ................
> 0x00000000 0x003ce5e0 0x00000000 0x00000000 .....<..........
>
>I look in ObjectAlloc and find this object. I look at the chain of allocation
events:
>AllocationEvent
>ObjectRetainedEvent
>ObjectAutoreleasedEvent
>ObjectRetainedEvent
>ObjectReleasedEvent
>ObjectReleasedEvent
>
>Shouldn't this be released when the current autorelease pool is cleared?
That's the wrong question to ask. The way to look at this data is (1) ignore
the autoreleased event, (2) count the allocation and retained events, (3)
subtract the count of released events. The result is 1, so the application
still has a retain count of 1 and is not deallocated.
Now, is that a leak? If you were expecting the object to be released by now
(the point in the app's operation where you paused and examined this
information), then yes. Otherwise, no.
To get more information on how the object got allocated, retained,
autoreleased, and released in each case, select it and use the Inspector.
You will see the backtrace (assuming that, as I instructed, you asked
ObjectAlloc to keep backtraces). As I said before, you need to use the
backtrace to match each increment in the retain count with the corresponding
decrement. You will then immediately know which corresponding decrement has
not yet happened.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins (at) lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden