开发者

Is there GC in latest iphone OS?

If we use NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; then what开发者_开发问答 method is used, either drain or release for lates iOS.


no garbage collection on iOS.

I do what apple suggests in the documentation:

In a garbage-collected environment, release is a no-op, so unless you do not want to give the collector a hint it is important to use drain in any code that may be compiled for a garbage-collected environment.


On iOS NSAutoreleasePool will drain when it goes out of the scope where it is defined (as long as no other reference is held). During the drain, it will release all objects held by it.

Thus, calling release might result in a drain, as long as it's the last reference to the pool.

This is different from the traditional GC where the collector is not scope bound and in general works independently of the main app code flow.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜