knowledge-database (beta)

Current group: comp.lang.objective-c

Memory managment

Memory managment  
Ole Andre Karlson
 Re: Memory managment  
Michael Ash
 Re: Memory managment  
Ole Andre Karlson
From:Ole Andre Karlson
Subject:Memory managment
Date:Tue, 11 Jan 2005 14:54:39 +0100
Hi,

ObjectAlloc tells me that each time I perform a certain task in my
application, 3 new objects of a specific type are created never to
disapear.

When I use the instance browser and look at the objects I see they all
have four events registerd.

AllocationEvent
ObjectRetainedEvent
ObjectReleasedEvent
ObjectReleasedEvent

In my simple understanding of objective-c this should bring their
retaincount to 0, and thus they should be dealloced.

Under what circumstances will an object with retaincount 0 not be
dealloced?

thanks
Ole Andre Karlson
ole@cognita.no
From:Michael Ash
Subject:Re: Memory managment
Date:Tue, 11 Jan 2005 08:19:04 -0600
Ole Andre Karlson wrote:
> Hi,
>
> ObjectAlloc tells me that each time I perform a certain task in my
> application, 3 new objects of a specific type are created never to
> disapear.
>
> When I use the instance browser and look at the objects I see they all
> have four events registerd.
>
> AllocationEvent
> ObjectRetainedEvent
> ObjectReleasedEvent
> ObjectReleasedEvent
>
> In my simple understanding of objective-c this should bring their
> retaincount to 0, and thus they should be dealloced.
>
> Under what circumstances will an object with retaincount 0 not be
> dealloced?

Commonly when this happens when you've overridden -dealloc but forgot to
call [super dealloc]; at the end. Since object deallocation is simply a
method in the superclass, not something handled by the compiler,
forgetting to call [super dealloc] means that the deallocation code will
never run.
From:Ole Andre Karlson
Subject:Re: Memory managment
Date:Tue, 11 Jan 2005 15:35:47 +0100
thanks, that was it :)

what a silly mistake...

Ole

> Ole Andre Karlson wrote:
>> Hi,
>>
>> ObjectAlloc tells me that each time I perform a certain task in my
>> application, 3 new objects of a specific type are created never to
>> disapear.
>>
>> When I use the instance browser and look at the objects I see they all
>> have four events registerd.
>>
>> AllocationEvent
>> ObjectRetainedEvent
>> ObjectReleasedEvent
>> ObjectReleasedEvent
>>
>> In my simple understanding of objective-c this should bring their
>> retaincount to 0, and thus they should be dealloced.
>>
>> Under what circumstances will an object with retaincount 0 not be
>> dealloced?
>
> Commonly when this happens when you've overridden -dealloc but forgot to
> call [super dealloc]; at the end. Since object deallocation is simply a
> method in the superclass, not something handled by the compiler,
> forgetting to call [super dealloc] means that the deallocation code will
> never run.
>
   

Copyright © 2006 knowledge-database   -   All rights reserved