Memory leak in UITableView when scrolling on iOS 5.1

A memory leak of 48 bytes occurs for each UITableview scroll. Responsible library: libsystem_c.dylib Responsible frame: strdup.

This is only observed on iOS 5.1, and not on earlier versions. Has anyone else come across the same? Is this a bug in iOS 5.1?

the code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath(NSIndexPath *)indexPath 
{
    NSString *cellIdentifier = [[NSString alloc] initWithString:@"fontSelectionCell"];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    [cellIdentifier release];

    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
    }       

    cell.textLabel.text = [fontNameList objectAtIndex:[indexPath row]];
    cell.selectionStyle =UITableViewCellSelectionStyleGray;
    cell.textLabel.font = [UIFont systemFontOfSize:17.0];

    if ([fontName isEqualToString:cell.textLabel.text])
    {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        cell.textLabel.textColor = [UIColor blueColor];

    }
    else
    {
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.textLabel.textColor = [UIColor blackColor]; 
    }

    return cell;
}
+3
source share
2 answers

I think you have this issue that has already reported iOS 5.1. I have it too. At the moment, I could not find a link on apple forums on this issue.

0
source

, . , , cellIndentifier, (.. dequeueReusableCellWithIdentifier).

/ - ( , , 100 , cellForRowAtIndexPath , ). .

.

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    static NSString *cellIdentifier = @"fontSelectionCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
    }   

   ...
}

cellIdentifier , ?

+1

All Articles