简体   繁体   English

如何在分配字符串值时解决内存泄漏

[英]How to solve memory leak at assigning string value

I have have observed that there is a memory leak at this code. 我已经观察到此代码存在内存泄漏。 I have released the workingEntry at this class. 我在这堂课上发布了workingEntry。

self.workingEntry.duration = [NSString stringWithFormat:@"%02d:%02d",[result minute], [result second]];

I inspect this using instruments in Xcode. 我使用Xcode中的工具对此进行了检查。 How can i solve this kind of memory leak? 我该如何解决这种内存泄漏?

If you have Zombies turned on in Scheme:Diagnostics then memory will not be released and everything will look like a memory leak. 如果您在Scheme:Diagnostics中启用了“僵尸”功能,则不会释放内存,并且所有内容看起来都像是内存泄漏。 Only test for memory leaks with Instruments if Zombies is turned off. 如果关闭了“僵尸”,则仅使用Instruments测试内存泄漏。

手动释放workEntry时,为什么不分配init并释放。

self.workingEntry.duration = [[NSString alloc]initWithFormat:@"%02d:%02d",[result minute], [result second]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM