Re: NSXMLParser frees itself on error?
Re: NSXMLParser frees itself on error?
- Subject: Re: NSXMLParser frees itself on error?
- From: Marcel Weiher <email@hidden>
- Date: Thu, 7 May 2009 10:05:29 -0700
On May 7, 2009, at 9:43 , Jeff Johnson wrote:
You misunderstand my argument. I'm not claiming that autorelease
provides some magical guarantee.
Actually, you were initially claiming that there was such a guarantee,
and misquoting the docs to 'prove' your point.
I'm claiming that you ought to write your code to provide the
guarantee. So, for example, don't wrap delegate callbacks in
autorelease pools. There's no need to 'clean up' after your
delegate, as you say. This is a not only a misapplication of memory
management responsibility, but it can lead to unintended and very
bad side effects.
That's an, er, interesting opinion.
Furthermore, I think you can count on Apple to not do anything like
that (and if they do, it's a bug they ought to fix). Why do you
think they suggest creating an autorelease pool inside your
NSXMLParser callback rather than just doing it themselves
automatically?
Because they forgot to do it initially, and then when they found that
their memory consumption was out of the ballpark wanted to add the
pools but couldn't because some client code they didn't want to break
was already assuming longer lifetimes than it had any rights to assume.
And yes, the code that I use explicitly runs the runloop, and it is
the code that runs the runloop that both allocates the NSURLConnection
and then cleans up after it checks the flag. Perfectly safe,
perfectly synchronous.
Cheers,
Marcel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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