Memory leak at Autorelease pool in Iphone sdk
- by monish
Hi guys,
I am getting leak at [pool release];
My code here is:
#pragma mark UISearchBarDelegate delegate methods
- (void)performSearch:(UISearchBar *)aSearchBar
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
artistName= [aSearchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([artistName length] > 0)
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
LyricsAppDelegate* appDelegate = (LyricsAppDelegate*) [ [UIApplication sharedApplication] delegate];
artistsList=[appDelegate doSearch:artistName ];
[theTableView reloadData];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[aSearchBar resignFirstResponder];
}
else
{
[aSearchBar resignFirstResponder];
}
[NSThread exit];
[pool release];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)aSearchBar
{
@try {
[NSThread detachNewThreadSelector:@selector(performSearch:) toTarget:self withObject:aSearchBar];
[aSearchBar resignFirstResponder];
}
@catch (NSException * e) {
NSLog(@"\n caught an exception");
}
@finally {
}
}
Here I am getting leak at [pool release]; in performSearch method.
How can I solve this.
Anyone's help will be much appreciated.
Thank you,
Monish.