sujithkrishnan
Jul 15, 2008, 04:14 AM
Hi,
I am attaching the screenshot of the INSTRUMENTS mem-leak stach trace.
When i go to the line mentioned in INSTRUMENTS, i found leak is in the following lines....
INSTRUMENTS Showing REALLOC in this line... ( I am calling this line many times in file, but i am not using any explicit alloc for any of variable)
This line is in a method and method returns me the NSData it recieved from URL, when i pass the URL to it...
-(NSData *)httpConnectionHandler:(NSString *)URL xmlString:(NSMutableString *)xmlDataInStringForm
{
NSString *URLString = [NSString stringWithFormat:@"http://stage.digby.com/30ss/%@?%@",URL,xmlDataInStringForm];
URLString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *orderRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URLString]];
[orderRequest addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[orderRequest setHTTPMethod:@"GET"];
NSURLResponse *orderResponse=nil;
NSError *orderResponseError=nil;
NSData *recievedOrderData = [NSURLConnection sendSynchronousRequest:orderRequest returningResponse:&orderResponse error:&orderResponseError];
return recievedOrderData;
}
Another leak is showing in this line
// praserObject is a property...
parserObject = [[NSXMLParser alloc] initWithData:receivedData1];
(I think in following line, the previous string is losing its reference, when we oveerwrite with new string...)
URLString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
But what wrong woth following?????????
Instruments showing
BOOL success = [NSKeyedArchiver archiveRootObject:[CustomerInfo getCustomerObject] toFile:writableDBPath];
if([[itemObject.iImg substringToIndex:4] isEqualToString:@"http"])
{
//NSAutoreleasePool *poolObj = [[NSAutoreleasePool alloc]init];
NSURL *urlString = [[NSURL alloc]initWithString:itemObject.imgName];
NSData *data = [[NSData alloc]initWithContentsOfURL:urlString];
UIImage *img = [[UIImage alloc]initWithData:data];
cell.image = img;
[img release];
[data release];
[urlString release]; //[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:itemObject.iImg]]];
//[poolObj drain];
}
else
{
cell.image = [UIImage imageNamed:itemObject.iImg];
}
state = 1;
}
return cell;
I am attaching the screenshot of the INSTRUMENTS mem-leak stach trace.
When i go to the line mentioned in INSTRUMENTS, i found leak is in the following lines....
INSTRUMENTS Showing REALLOC in this line... ( I am calling this line many times in file, but i am not using any explicit alloc for any of variable)
This line is in a method and method returns me the NSData it recieved from URL, when i pass the URL to it...
-(NSData *)httpConnectionHandler:(NSString *)URL xmlString:(NSMutableString *)xmlDataInStringForm
{
NSString *URLString = [NSString stringWithFormat:@"http://stage.digby.com/30ss/%@?%@",URL,xmlDataInStringForm];
URLString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *orderRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URLString]];
[orderRequest addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[orderRequest setHTTPMethod:@"GET"];
NSURLResponse *orderResponse=nil;
NSError *orderResponseError=nil;
NSData *recievedOrderData = [NSURLConnection sendSynchronousRequest:orderRequest returningResponse:&orderResponse error:&orderResponseError];
return recievedOrderData;
}
Another leak is showing in this line
// praserObject is a property...
parserObject = [[NSXMLParser alloc] initWithData:receivedData1];
(I think in following line, the previous string is losing its reference, when we oveerwrite with new string...)
URLString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
But what wrong woth following?????????
Instruments showing
BOOL success = [NSKeyedArchiver archiveRootObject:[CustomerInfo getCustomerObject] toFile:writableDBPath];
if([[itemObject.iImg substringToIndex:4] isEqualToString:@"http"])
{
//NSAutoreleasePool *poolObj = [[NSAutoreleasePool alloc]init];
NSURL *urlString = [[NSURL alloc]initWithString:itemObject.imgName];
NSData *data = [[NSData alloc]initWithContentsOfURL:urlString];
UIImage *img = [[UIImage alloc]initWithData:data];
cell.image = img;
[img release];
[data release];
[urlString release]; //[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:itemObject.iImg]]];
//[poolObj drain];
}
else
{
cell.image = [UIImage imageNamed:itemObject.iImg];
}
state = 1;
}
return cell;
