开发者

Autorelease with elements in a UITableViewCell - memory leak

开发者 https://www.devze.com 2023-01-03 16:32 出处:网络
In my \'cellForRowAtIndexPath\' method for a UITableView delegate, I\'m allocating a cell if it doesn\'t exist, and in this cell, I\'m creating a new activity spinner like so:

In my 'cellForRowAtIndexPath' method for a UITableView delegate, I'm allocating a cell if it doesn't exist, and in this cell, I'm creating a new activity spinner like so:

UIActivityIndicatorView *actView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray ] autorelease];

I'm using Leaks to detect memory leaks in my program, and for some reason, this is coming up as a leak, even though it's autoreleasing. The cell itself is also autoreleasing. Has anyone had experience with autoreleasing variables coming up as leaks in the Leaks instrument, and how to tackle these problems?

This is only leaking if I add it to the cell's contentView. If I just create it and let it be, the Leak instrument doesn't report any problem.

Also, if it helps, this is the history Leaks is displaying for this memo开发者_JS百科ry location. It looks like it at some point gets an additional retain message? This is not being done in my code.

Autorelease with elements in a UITableViewCell - memory leak


Is the containing cell being released?

If not, are you ever removing the UIActivityIndicatorView instance from the containing cell?


I've come to the conclusion that this is due to the simulator - I do not receive these leaks on the actual device.

0

精彩评论

暂无评论...
验证码 换一张
取 消