简体   繁体   中英

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.

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

I inspect this using instruments in 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. Only test for memory leaks with Instruments if Zombies is turned off.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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