Re: memory leak in readInBackgroundAndNotify
Re: memory leak in readInBackgroundAndNotify
- Subject: Re: memory leak in readInBackgroundAndNotify
- From: "Gurmit Teotia" <email@hidden>
- Date: Sat, 22 Apr 2006 12:29:30 +0530
Thanks for your input Ondra.I would like to add some more inputs here which
leads me to confusion:
1. If I trace the notification read method in ObjectAlloc program it is
being called from NSAppication's run so my undertanding is that before each
notifcation a autorelease pool is created just like in case of button event.
2. I further confirmed that by declaring the "mData" as instance variable.
After a read operation I tried to print(log) "mData" on the event of other
button but my application was crashing. Which leads me to believe that
"mData" is created in autorelease pool on notification which no more exists.
>>Notifications are not events. Therefore, many notifications may be served
by one pool
Did you mean here that a seperate autorelease pool is not created on
notifications like events? Could you please give some more explaination by
considering the above observations.
Regards,
Gurmit
On 4/21/06, Ondra Cada <email@hidden> wrote:
>
> Gurmit,
>
> On Apr 21, 2006, at 1:03 PM, Gurmit Teotia wrote:
>
> > Thanks Greg & Ondra. I think I've to read more to clear my
> > understanding. But still this behaviour is confusing to me. For
> > time being I have use nested autorelease pool. Later on when I get
> > more familiar with it,
>
> Actually, there is a simple yet quite satisfactory rule of thumb:
>
> (a) if you are autoreleasing a comparatively small number of
> comparatively small objects, leave it on the framework;
> (b) whenever that what you autorelease is very big or there's a great
> number of a-ed objects, use a nested pool.
>
> There still are *some* exceptions (like that you have to use extra
> pool always in +load or threads), but in a very vast majority of
> cases those (a) and (b) above would work well.
>
> > I think I'll be able to understand where is the problem.
>
> Well, very roughly: automatic pools are created/released on event
> boundaries. Notifications are not events. Therefore, many
> notifications may be served by one pool. OTOH, clicking is an event,
> and therefore each click on a button is served by a separate pool.
> ---
> Ondra Čada
> OCSoftware: email@hidden http://www.ocs.cz
> private email@hidden http://www.ocs.cz/oc
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden