tags:

views:

116

answers:

0

Default Getting Memory Issues when Using Libxml2 Hi all,

This is the code we are using for application,I fgiving where we are getting the leaks.

  • (void)connectionNSURLConnection *)connection didReceiveDataNSData *)data {

xmlParseChunk(context, (const char *)[data bytes], [data length], 0);

Here we are getting the leak

}

  • (void)downloadAndParseNSURL *)url { self.downloadAndParsePool = [[NSAutoreleasePool alloc] init]; done = NO; self.parseFormatter = [[[NSDateFormatter alloc] init] autorelease]; [parseFormatter setDateStyle:NSDateFormatterLongStyle]; [parseFormatter setTimeStyle:NSDateFormatterNoStyle]; // necessary because iTunes RSS feed is not localized, so if the device region has been set to other than US // the date formatter must be set to US locale in order to parse the dates [parseFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; self.characterBuffer = [NSMutableData data]; [[NSURLCache sharedURLCache] removeAllCachedResponses]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:url]; // create the connection with the request and start loading the data rssConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; // This creates a context for "push" parsing in which chunks of data that are not "well balanced" can be passed // to the context for streaming parsing. The handler structure defined above will be used for all the parsing. // The second argument, self, will be passed as user data to each of the SAX handlers. The last three arguments // are left blank to avoid creating a tree in memory. context = xmlCreatePushParserCtxt(&simpleSAXHandlerStruct, self, NULL, 0, NULL);

Here we are getting one leak

[self performSelectorOnMainThread:@selector(downloadStar ted) withObject:nil waitUntilDone:NO]; if (rssConnection != nil) { do { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } while (!done); } // Release resources used only in this thread. xmlFreeParserCtxt(context); self.characterBuffer = nil; self.parseFormatter = nil; self.rssConnection = nil; self.currentSong = nil; [downloadAndParsePool release]; self.downloadAndParsePool = nil; }

Can any one please help me this one is very urgent for us.