Skip navigation.
 
mlRe: Memory management with arrays
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
>

Related mailsAuthorDate
mlMemory management with arrays Jacob Bandes-Storc… Feb 10, 04:48
mlRe: Memory management with arrays Jonathon Mah Feb 10, 07:10
mlRe: Memory management with arrays Jacob Bandes-Storc… Feb 10, 07:12
mlRe: Memory management with arrays Andrew Merenbach Feb 10, 07:12
mlRe: Memory management with arrays Scott Andrew Feb 10, 07:16
mlRe: Memory management with arrays Bill Bumgarner Feb 10, 07:38
mlRe: Memory management with arrays ss2 cire Feb 10, 07:57
mlRe: Memory management with arrays Bill Bumgarner Feb 10, 08:02
mlRe: Memory management with arrays ss2 cire Feb 10, 08:13
mlRe: Memory management with arrays Scott Andrew Feb 10, 14:36
mlRe: Memory management with arrays Bill Bumgarner Feb 10, 18:39
mlRe: Memory management with arrays Adhamh Findlay Feb 10, 19:23