2013-02-18 142 views
1

我的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

回答

0

試試這個

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