Autoforget Pool?

Posts: 241
Joined: 2008.07
Post: #1
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.
Quote this message in a reply
⌘-R in Chief
Posts: 1,277
Joined: 2002.05
Post: #2
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.
Quote this message in a reply
Post Reply