Re: NSXML & Auto Release Pools
Re: NSXML & Auto Release Pools
- Subject: Re: NSXML & Auto Release Pools
- From: James Montgomerie <email@hidden>
- Date: Wed, 4 Feb 2009 18:38:37 +0000
On 4 Feb 2009, at 18:06, Alan Shouls wrote:
I am using NSXML in a C++ and am working through some test cases and
have
come across something I can't quite figure out. Here is what I do:
1. Create an Auto Release Pool
2. Create an NSXML object using [NSXMLDocument alloc] initWithData:
(NSData
*)data options:NSXMLNodeOptionsNone error:pError]
3. Release the Auto Release Pool
4. Release my NSXML object
I then get a warning NSCFString autoreleased with no pool in place -
just
leaking
If, however I do things so that I release my NSXML object before
releaseing
the Auto Release Pool - no message.
The NSXML object is probably calling autorelease on something in its
dealloc method (this is perfectly legal, and should generally be seen
as implementation detail - you're just seeing a side effect of it here).
In general, you need to wrap your /entire/ Cocoa usage in an
autorelease pool if you're using it in a non-Cocoa app (or a thread
that doesn't otherwise have a pool pre-created for you), to account
for just this sort of thing.
Jamie.
_______________________________________________
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