English 中文(简体)
显示NSPlace持有人泄漏的仪器
原标题:instruments showing NSPlaceholderstring leaks

我试图减少我的照片中的记忆泄露,因此,我利用仪器发现所有泄漏。 我设法消除了几乎所有的泄露,但空洞除外。

Instruments is telling me that i have a lot of NSPlaceholderstring leaks. The code that generated the leak (according to instruments) is:

if (nil == storedHash) 
{
  NSString *description = [[NSString alloc] initWithFormat:@"1 = %@ 2= %d", uId, service];
  self.storedHash = description; // This line is the leak according to instruments

  [description release];
  description = nil;
}

return storedHash

储存 哈希的定义类似:

@property(copy) NSString* storedHash;

I tried everything i can think of:

  • I used retain instead of copy
  • I used an autorelease allocation of the NSString (stringWithFormat)
  • I tried wrapping the code with an autorelease pool

上述任何内容都没有改变泄漏。 (在某些情况下,泄漏的变化类型,但仍有泄漏)

是谁?

问题回答

哪里? 您是否在<条码>上公布。

注:<代码>NSPlaceholdeString是一个执行细节;通过<代码>NSString s+alloc退回的类别。

如何使用<代码>dealloc方法? 你们是否释放了交易方法中储存的Hash? 如何核对<代码>if(nil ==自封的Hash)。

你们应当使用

@property(nonatomic, retain) NSString* storedHash;

相反,抄本。 @property(copy) don t release You original NSObject and You should do it yourself:

if (nil == storedHash) 
{
  NSString *description = [[NSString alloc] initWithFormat:@"1 = %@ 2= %d", uId, service];
  [self.storedHash release];
  self.storedHash = description; // This line is the leak according to instruments

  [description release];
  // description = nil; // it s unnecessary
}

也请你释放储存的物资 Hash in distrac.





相关问题
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风格的解决办法,只是一个简单的袖珍流程......

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

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

热门标签