Stuart
Stuart

Reputation: 41

Where is the leak?

I have been using an RSS reader code example but have found a leak in the parser.

here's the code...

-(BOOL)fetchAndParseRss{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

     [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

     //To suppress the leak in NSXMLParser
     [[NSURLCache sharedURLCache] setMemoryCapacity:0];
     [[NSURLCache sharedURLCache] setDiskCapacity:0];

     NSURL *url = [NSURL URLWithString:@"http://www.bnp.org.uk/?q=rss.xml"];
     BOOL success = NO;
     NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
     [parser setDelegate:self];
     [parser setShouldProcessNamespaces:YES];
     [parser setShouldReportNamespacePrefixes:YES];
     [parser setShouldResolveExternalEntities:NO];
     success = [parser parse];
     [parser release];
     [pool drain];
     return success;
}

Can you help?

Upvotes: 0

Views: 205

Answers (1)

nacho4d
nacho4d

Reputation: 45118

NSXMLParser has a leak, is a bug from Apple. Bug #6469143. I don't think they have solved in iOS4. (At least not in the Simulator) Please see this: NSXMLParser Leaking

Upvotes: 1

Related Questions