I am getting leaks in Master view controller of iPhone.
When I call this method, I am inserting them into filteredListCount array, because when I search I need to show the list from filteredListCount array otherwise customerArray.
This functionality is working fine but I am getting leaks in the method below at allocation: filteredListCount = [[NSMutableArray alloc] initWithCapacity: [customerArray count]];
This is the first view controller of my application, I am showing the list and I am also allowing to search from a list.
- (void)parser:(CustomerListLibXmlParser *)parser addCustomerObject:(Customer *)customerObj1
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[customerArray addObject:customerObj1];
filteredListCount = [[NSMutableArray alloc] initWithCapacity: [customerArray count]];
[filteredListCount addObjectsFromArray: customerArray];
[theTableView reloadData];
}
- (void)parser:(CustomerListLibXmlParser *)parser encounteredError:(NSError *)error
{
}
- (void)parserFinished:(CustomerListLibXmlParser *)parser
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
self.title=@"Customers";
}
There’s no garbage collection on the iphone. If filteredListCount is already pointing to a block of memory that’s been allocated, and you assign something else to it, that block will continue to exist.
Empty out filteredListCount first.
Or, just use a retain property instead.