iDevGames Forums
Autoforget Pool? - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: Autoforget Pool? (/thread-10315.html)

Autoforget Pool? - bmantzey - Sep 21, 2012 01:36 PM

I'm not sure what's going on here. The autorelease pool doesn't seem to be doing anything in this case. I see it works most of the time, but I've noticed that it does nothing at other times.

I'm troubleshooting a memory leak. In instruments, for the object I'm troubleshooting, the count looks like this:

0: Malloc 1
1: Autorelease
2: Retain 2
3: Retain 3
4: Release 2

... there are several more lines in the object's life, but none of them are a drain.

It just so happens that the object is created and autorelease is called on it inside the delegate method of UITableViewDelegate -
(UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath

Among a bunch of other stuff not related to the lifecycle of this cell, this appears to be the significant code:

    FolderListCellView *cell = (FolderListCellView*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[[FolderListCellView alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease];

where FolderListCellView inherits from UITableViewCell

The question I have is, why does the autorelease pool never drain this autorelease object? I don't understand why a blank appears by the autorelease call and the object never receives the release. I hope someone can help. Thanks.

RE: Autoforget Pool? - SethWillits - Sep 21, 2012 06:02 PM

Because it's being retained by the table view in its reuse queue.

You did your part correctly. What you showed is not the source of any leak.