Re: NSURL leaking 1.7kb ?
Re: NSURL leaking 1.7kb ?
- Subject: Re: NSURL leaking 1.7kb ?
- From: nick briggs <email@hidden>
- Date: Fri, 25 Mar 2005 12:10:11 +0000
I should add that the following doesn't leak.
CFXMLTreeRef tree;
tree = CFXMLTreeCreateWithDataFromURL(kCFAllocatorDefault,
(CFURLRef)_url,
kCFXMLParserSkipWhitespace,
NULL );
Nick
On 25 Mar 2005, at 11:58, nick briggs wrote:
Actuall Dave, in my _real_ code I am releasing the NSURL:
- (void)_setURL:sender
{
if([[sender stringValue]length])
{
NSString *path = [sender stringValue];
// url validation here
[_url release];
_url = [[NSURL URLWithString:path]retain];
[self _download];
}
}
I've been told that
------
"I found a leak in ANY synchronous URL loading routings
roughly 1 year ago. DTS confirmed it. Up to the moment of
time, I received no notice, that Apple fixed it.
A simple solution is to skip synchronous URL loading all over.
As far as I know, all async routines are fine."
---------
Although I find that async routines leak also, as below
[_url loadResourceDataNotifyingClient:self usingCache:NO];
- (void)URLResourceDidFinishLoading:(NSURL *)sender
{
NSData *data = [sender resourceDataUsingCache:NO];
if(data){
_parser = [[NSXMLParser alloc] initWithData:data];
[_parser setDelegate:self];
[_parser parse];
}else{
NSLog(@"%@ failed to download xml data: %@", [self class], [_url absoluteString]);
}
}
Anyone care to confirm or otherwise?
Nick
On 23 Mar 2005, at 19:40, David Maclachlan wrote:
NSURL *_url;
_url = [[coder decodeObjectForKey:@"url"]retain];
or in the case of a new document:
_url = [[NSURL URLWithString:_path]retain];
So, nothing unusual there. I then routinely use the NSURL to either instantiate a NSXMLParser:
Since you've retained the URL, you're responsible for releasing it. I didn't see a release call anywhere in your sample code.
Cheers,
Dave
_______________________________________________
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