I have a UITableView with a cellForRowAtIndexPath
method that creates a UITextView, then adds it to a cell. No memory leaks were detected, but when running Instruments (Object Allocations), the Net memory is on a one-way trip to 18 MB, where it crashes.
My app constantly adds and deletes cells in the tableView datasource, but because the TextView is released, I can see no way memory could be piling up.
Here is my cellForRowAtIndexPath
code:
static NSString *cellIdentifier=@"Cell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil) {
// Build cell
cell=[[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease];
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
UITextView *tv=[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 95)];
tv.font=[UIFont fontWithName:@"Helvetica-Bold" size:16];
tv.text=@"My Cell Text";
[cell addSubview:tv];
[tv release];
return cell;
Thanks in advance!