开发者

NSString Memory Leak Issue, How to autorelease a NSttring?

开发者 https://www.devze.com 2023-02-23 04:37 出处:网络
I have some NSString inside my program.If I did a release I think its finished using, it crashed the program.If I don\'t release them , it cause memory leakage quite a bit.

I have some NSString inside my program. If I did a release I think its finished using, it crashed the program. If I don't release them , it cause memory leakage quite a bit. [string1 autorelease] cause executive bad access.

It giving me all kinds of headache开发者_如何学C.


release and autorelease is both releasing, just at different points in time. So if one crashes, most likely the other one will as well.

You need to get your memory management right. Maybe use NSZombies, and the static analyzer might be a good helper, too. Also, the debugger might stop right away at the object that causes the problems.

I suggest to read the memory management guide: http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

0

精彩评论

暂无评论...
验证码 换一张
取 消