Iphone 奇怪的内存泄漏
我的iPad应用程序几乎没有内存泄漏。这是屏幕截图和代码。我在每秒钟后重新加载表数据以显示进度。那么我如何才能获得此修复 这总是发生在我重新加载表时Iphone 奇怪的内存泄漏,iphone,ios,ipad,Iphone,Ios,Ipad,我的iPad应用程序几乎没有内存泄漏。这是屏幕截图和代码。我在每秒钟后重新加载表数据以显示进度。那么我如何才能获得此修复 这总是发生在我重新加载表时 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* I
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* Identifier = @"OrderCustomCell";
UserCustomCell* cells =(UserCustomCell*) [tableView dequeueReusableCellWithIdentifier:Identifier];
if (cells == nil)
{
NSArray* topLevelObjects=[[NSBundle mainBundle] loadNibNamed:@"UserCustomCell" owner:self options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[UITableViewCell class]])
{
cells=(UserCustomCell *)currentObject;
break;
}
}
}
NSDictionary* dic = [tableDataArray objectAtIndex:indexPath.row];
cells.selectionStyle = UITableViewCellEditingStyleNone;
cells.brandName.text = [dic objectForKey:@"brandname"];
[cells.msyncBtn setTag:indexPath.row];
NSString* status = [dic objectForKey:@"status"];
if ([status isEqualToString:@""])
{
cells.status.text = [NSString stringWithFormat:@"0%@ Completo",@"%"];
}
else
{
cells.status.text = [NSString stringWithFormat:@"%@%@ Completo",status,@"%"];
}
NSString* syncDate = [dic objectForKey:@"syncDate"];
if ([syncDate isEqualToString:@""])
{
cells.syncDate.text = [NSString stringWithFormat:@"Não sincronizado"];
}
else
{
cells.syncDate.text = [NSString stringWithFormat:@"%@",syncDate];
}
NSString* totalloaded = [dic objectForKey:@"totalloaded"];
if ([totalloaded isEqualToString:@""])
{
cells.totalLoaded.text = [NSString stringWithFormat:@""];
}
else
{
cells.totalLoaded.text = [NSString stringWithFormat:@"%@",totalloaded];
}
return cells;
}
请检查这张图片
试试这个
if (cells == nil)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSArray* topLevelObjects=[[NSBundle mainBundle] loadNibNamed:@"UserCustomCell" owner:self options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[UITableViewCell class]])
{
cells=(UserCustomCell *)currentObject;
break;
}
}
[pool drain];
}
您的仪器屏幕截图显示的是内存分配,而不是泄漏。首先分配NSArray和NSDictionary,然后分配