`
hqman
  • 浏览: 352982 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

cocoa 内存管理笔记

阅读更多

经常碰到 EXC_BAD_ACCESS 调试程序十分麻烦,只好回头看书

 

Here are the rules:
 ■ When you create an object using new, alloc, or copy, the object has a retain count
of 1. You are responsible for sending the object a release or autorelease message
when you’re done with it. That way, it gets cleaned up when its useful life is over.

 

 


 ■ When you get hold of an object via any other mechanism, assume it has a retain
count of 1 and that it has already been autoreleased. You don’t need to do any fur-
ther work to make sure it gets cleaned up. If you’re going to hang on to the object for
any length of time, retain it and make sure to release it when you’re done.


 ■ If you retain an object, you need to (eventually) release or autorelease it. Balance
these retains and releases.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics