Getting memory leak at NSURL connection in Iphone sdk.
Posted
by
monish
on Stack Overflow
See other posts from Stack Overflow
or by monish
Published on 2010-07-06T06:32:11Z
Indexed on
2010/12/24
19:54 UTC
Read the original article
Hit count: 207
Hi guys,
Here Im getting leak at the NSURL connection in my libxml parser can anyone tell how to resolve it.
The code where leak generates is:
- (BOOL)parseWithLibXML2Parser
{
BOOL success = NO;
ZohoAppDelegate *appDelegate = (ZohoAppDelegate*) [ [UIApplication sharedApplication] delegate];
NSString* curl;
if ([cName length] == 0)
{
curl = @"https://invoice.zoho.com/api/view/settings/currencies?ticket=";
curl = [curl stringByAppendingString:appDelegate.ticket];
curl = [curl stringByAppendingString:@"&apikey="];
curl = [curl stringByAppendingString:appDelegate.apiKey];
curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""];
}
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:curl]];
NSLog(@"the request parserWithLibXml2Parser %@",theRequest);
NSURLConnection *con = [[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] autorelease];//Memory leak generated here at this line of code.
//self.connection = con;
//[con release];
// 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.
_xmlParserContext = xmlCreatePushParserCtxt(&simpleSAXHandlerStruct, self, NULL, 0, NULL);
if(con != nil)
{
do
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
} while (!_done && !self.error);
}
if(self.error)
{
//NSLog(@"parsing error");
[self.delegate parser:self encounteredError:nil];
} else
{
success = YES;
}
return success;
}
Anyone's help will be muck appreciated .
Thank you, Monish.
© Stack Overflow or respective owner