奇怪的内存泄漏

奇怪的内存泄漏

问题描述:

我的iPad应用程序面临少量内存泄漏。这里是屏幕快照和代码。我每秒钟后都会加载表格数据以显示进度。如何获得此修复程序。奇怪的内存泄漏

当我重新加载表这总是发生

// 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; 
} 

请检查该图像

screenshot 1

+0

您的仪器的屏幕截图显示的内存分配,不是泄漏。 – lqs 2013-02-18 08:27:07

+0

首先分配你的'NSArray'和'NSDictionary',然后分配 – MadhuP 2013-02-18 08:55:36

试试这个

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]; 
} 
+0

让我知道..如果它不起作用。 – SachinVsSachin 2013-02-18 08:25:10