FROM : Scott Andrew
DATE : Sun Feb 10 14:36:25 2008
True.. (late night). So basically. Put a break in bar's dealloc. See
were the extra dealloc is cooming from.
Scott
On Feb 9, 2008, at 10:38 PM, Bill Bumgarner wrote:
> On Feb 9, 2008, at 10:16 PM, Scott Andrew wrote:
>> Here is my guess, just because i hit this recently. It had to do
>> with the [bar autorelease] call. This returns an autoreleased
>> object. That may not be valid when you cam back around to
>> removeAllObjects. Try the following:
>>
>> void foo
>> {
>> [array removeAllObjects];
>>
>> Bar* bar = [[Bar alloc] init];
>> [array addObject:bar];
>> [bar release];
>> }
>>
>> the following should also work..
>>
>> void foo
>> {
>> [array removeAllObjects];
>>
>> Bar* bar = [[[Bar alloc] init] autorelease];
>>
>> [array addObject:bar];
>
> The OP's code, as posted, was fine. -autorelease returns the
> object being autoreleased and alloc returns an object that has been
> retained.
>
> Most likely, OP has overreleased one of the objects in the array.
> Run with NSZombieEnabled to see what object is being overreleased.
> Better yet, turn on malloc stack logging (no compact) and use
> malloc_history to see allocation events at that address.
>
> b.bum
>
DATE : Sun Feb 10 14:36:25 2008
True.. (late night). So basically. Put a break in bar's dealloc. See
were the extra dealloc is cooming from.
Scott
On Feb 9, 2008, at 10:38 PM, Bill Bumgarner wrote:
> On Feb 9, 2008, at 10:16 PM, Scott Andrew wrote:
>> Here is my guess, just because i hit this recently. It had to do
>> with the [bar autorelease] call. This returns an autoreleased
>> object. That may not be valid when you cam back around to
>> removeAllObjects. Try the following:
>>
>> void foo
>> {
>> [array removeAllObjects];
>>
>> Bar* bar = [[Bar alloc] init];
>> [array addObject:bar];
>> [bar release];
>> }
>>
>> the following should also work..
>>
>> void foo
>> {
>> [array removeAllObjects];
>>
>> Bar* bar = [[[Bar alloc] init] autorelease];
>>
>> [array addObject:bar];
>
> The OP's code, as posted, was fine. -autorelease returns the
> object being autoreleased and alloc returns an object that has been
> retained.
>
> Most likely, OP has overreleased one of the objects in the array.
> Run with NSZombieEnabled to see what object is being overreleased.
> Better yet, turn on malloc stack logging (no compact) and use
> malloc_history to see allocation events at that address.
>
> b.bum
>
| Related mails | Author | Date |
|---|---|---|
| Jacob Bandes-Storc… | Feb 10, 04:48 | |
| Jonathon Mah | Feb 10, 07:10 | |
| Jacob Bandes-Storc… | Feb 10, 07:12 | |
| Andrew Merenbach | Feb 10, 07:12 | |
| Scott Andrew | Feb 10, 07:16 | |
| Bill Bumgarner | Feb 10, 07:38 | |
| ss2 cire | Feb 10, 07:57 | |
| Bill Bumgarner | Feb 10, 08:02 | |
| ss2 cire | Feb 10, 08:13 | |
| Scott Andrew | Feb 10, 14:36 | |
| Bill Bumgarner | Feb 10, 18:39 | |
| Adhamh Findlay | Feb 10, 19:23 |






Cocoa mail archive

