0

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?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Stuart
  • 41
  • 4

1 Answers1

1

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

Community
  • 1
  • 1
nacho4d
  • 43,720
  • 45
  • 157
  • 240
  • Thanks for that. Although there must be times when NSXMLParser is okay, the XML Performance test app on the Dev centre works okay. Any way I have found a great ready made RSS Parser from a great guy named Michael Waterfall at http://github.com/mwaterfall/MWFeedParser it works straight out of the box. So many thanks to Michael. – Stuart Jul 01 '10 at 05:44