English 中文(简体)
NSMutable的记忆泄漏 理论
原标题:Memory leaks in NSMutableDictionary
  • 时间:2010-07-30 10:18:59
  •  标签:
  • iphone

在操作仪器时,将存储信息从以下线上泄露出来,“(NSString *)编码”是指从服务器上抽取的“JSON”反应器,扫描任何给器,并了解如何固定这种记忆的泄漏,

Thanks, Sam,

www.un.org/Depts/DGACM/index_spanish.htm

 NSMutableDictionary *allCards = [NSMutableDictionary dictionary];

CardTypeDTO *cardTypeDTO = [[CardTypeDTO alloc] init];

  [cardTypeDTO setImageURL:[[CommonUtility urlDecode:[cardDetail objectForKey:@"imageURL"]] retain]];

  [allCards setValue:cardTypeDTO forKey:[cardDetail objectForKey:@"accountId"]];



-(id)parseFeed:(NSString *)feedString{

 //NSMutableDictionary *allCards = [[NSMutableDictionary alloc] init];
 NSMutableDictionary *allCards = [NSMutableDictionary dictionary];


 NSMutableDictionary *parsedOutput = (NSMutableDictionary *)feedString;

 NSArray *objectKeys = [parsedOutput allKeys];


 for (int i = 0; i < [objectKeys count]; i++) {
  NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
  NSMutableDictionary *cardDetail = [parsedOutput objectForKey:[objectKeys objectAtIndex:i]];
  CardTypeDTO *cardTypeDTO = [[CardTypeDTO alloc] init];
  [cardTypeDTO setAccountId:[cardDetail objectForKey:@"accountId"]];
  [cardTypeDTO setCardName:[cardDetail objectForKey:@"cardName"]];
  [cardTypeDTO setBankName:[cardDetail objectForKey:@"bankName"]];
  [cardTypeDTO setCustomMessage:[cardDetail objectForKey:@"customMessage"]];
  [cardTypeDTO setAvailableAmount:[cardDetail objectForKey:@"availableAmount"]];
  [cardTypeDTO setBalanceAmount:[cardDetail objectForKey:@"balanceAmount"]];
  [cardTypeDTO setPercentage:[cardDetail objectForKey:@"percentage"]];
  //[cardTypeDTO setImageURL:[cardDetail objectForKey:@"imageURL"]];
  [cardTypeDTO setImageURL:[[CommonUtility urlDecode:[cardDetail objectForKey:@"imageURL"]] retain]];
  [cardTypeDTO setNickName:[cardDetail objectForKey:@"nickName"]];
  [cardTypeDTO setBalanceStatusCode:[cardDetail objectForKey:@"balanceStatusCode"]];
  [cardTypeDTO setBalanceStatusMsg:[cardDetail objectForKey:@"balanceStatusMsg"]];
  [cardTypeDTO setOnlineLinked:[cardDetail objectForKey:@"onlineLinked"]];
  [cardTypeDTO setCardType:[cardDetail objectForKey:@"cardType"]];

  [allCards setValue:cardTypeDTO forKey:[cardDetail objectForKey:@"accountId"]];
  //[cardTypeDTO release];
  [loopPool release];

 }

 return allCards;
}

+(NSString *) urlDecode: (NSString *) url
{
 NSString *result=[url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
 return [result autorelease];
}

最佳回答

确实需要审查记忆规则。 例如

+(NSString *) urlDecode: (NSString *) url
{
   NSString *result=[url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
   return [result autorelease];
}

扼杀ByReplacePercentE的替罪羊的结果是已经自动释放的,你正在将其再次自动化。

回国后,你这样做:

[cardTypeDTO setImageURL:[[CommonUtility urlDecode:[cardDetail objectForKey:@"imageURL"]] retain]]

一种综合保留@property? 如果是的话,它就保留了电话。

cardTypeDTO > 保留了Count 1,然后添加到保留该编号的字典上(发送了保留)。

我写道,这可能有助于:

这里还有另一个很好的解释。

问题回答

我感到惊讶的是,它根本就发挥了作用。 页: 1 如果是正确的,由于不寻常的法典,泄漏可能只是虚假的。

我看不到<代码>feedString的漏水,但我确实见cardTypeDTO。 您对<代码>release作了评论,但这不是正确的。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签