title: Memory leak in UIImage's imageWithContentsOfFile
body: <p>I have a table view with 10 cells displaying an image. Everytime I scroll, the app allocates more memory (but doesn't show this in leaks) but in allocations, I can see that memory increases by like 2 megabytes with each scroll.</p>
  
  <p>This is the code which leaks, specifically the line where i set the imageview's image (if I comment it out, it doesn't leak):</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (!cell) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
      cell.imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background_stripes" ofType:@"png"]];
      return cell;
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ElOFi.png" alt="enter image description here"></p>
  
  <p><strong>UPDATE:</strong> I created a simple new project with 1 view controller:</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      self.tableView.rowHeight = 130.f;
  
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return 16;
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (!cell) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
      cell.imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background_stripes" ofType:@"png"]];
  
  
      return cell;
  }
  </code></pre>
  
  <p>Very simple...I don't see any problem here...but leaks when I scroll, the memory consumption grows over time...</p>