Memory leak at Autorelease pool in Iphone sdk

Posted by monish on Stack Overflow See other posts from Stack Overflow or by monish
Published on 2010-03-25T09:37:21Z Indexed on 2010/03/25 9:43 UTC
Read the original article Hit count: 387

Filed under:

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.

© Stack Overflow or respective owner

Related posts about objective-c