【发布时间】:2011-11-18 18:07:51
【问题描述】:
我有一个包含 1000 个元素的 UITableView。在第一次加载它之前 Instruments 显示 2.20MB 的字节仍然存在。充电后显示4.82MB。当我释放内存并返回之前的状态时,它显示为 4.71MB。但是现在当我加载同一张表时,仪器再次显示 4.82MB。 UITableView 的结构是否存储在缓存中?如果是,有什么办法可以释放这段内存?
我的表结构:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"SearchResult";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
}
if(!isSomeStateSearching) cell.textLabel.text = [[[contentSomeState objectAtIndex:indexPath.section] objectForKey:@"rowValues"] objectAtIndex:indexPath.row];
else
{
cell.textLabel.text = [searchedAllContent objectAtIndex:indexPath.row];
}
UIView *v = [[[UIView alloc] init] autorelease];
v.backgroundColor = [UIColor colorWithRed:188/255.0 green:57/255.0 blue:25/255.0 alpha:1.0];
cell.selectedBackgroundView = v;
UIImageView *arrow = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seta_navegacao"]] autorelease];
cell.accessoryView = arrow;
return cell;
}
【问题讨论】:
标签: iphone objective-c ios uitableview memory-management