Search code examples
iosimagememory-warning

Images not release in memory


I have table with Images cell. Images download from internet and save in local disk. Count = 200. Tableview show this images. When scroll content to bottom, comes message memory warning... Used memory 250 - 300 mb O_O!!! Links to images that do not keep.

NSString *cellID = @"cellId";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
...
NSString* imagePath = [arrayContent objectAtIndex:indexPath.row];
UIImage* image = [[UIImage alloc] initWithContentsOfFile:imagePath];
[cell.imageView setImage:image];

Why hide images not release?


Solution

  • Replace this line

    UIImage* image = [[UIImage alloc] initWithContentsOfFile:imagePath];
    

    with this and check once

     UIImage *image = [UIImage imageWithContentsOfFile:imagePath];