现在的位置: 首页 > 综合 > 正文

autorelease对象的释放

2019年10月01日 ⁄ 综合 ⁄ 共 686字 ⁄ 字号 评论关闭

aotorelease对象具体是什么时候释放?

The autoreleased objects will be deallocated when, the closest enclosing autorelease pool on the stack of the thread on which the -autorelease message has been sent, gets drained or released.

对于每一个Runloop, 系统会隐式创建一个Autorelease pool,这样所有的release pool会构成一个象CallStack一样的一个栈式结构,在每一个Runloop结束时,当前栈顶的Autorelease pool会被销毁,这样这个pool里的每个Object会被release。

关于Runloop,请问文档:

https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html

https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003725

自:http://www.cocoachina.com/bbs/simple/?t93572.html

抱歉!评论已关闭.