Autorelease pools in appkit applications

六月ゝ 毕业季﹏ 提交于 2019-12-10 00:36:30

问题


I'm having difficulties to understand exactly WHEN autorelease pools are created and released in AppKit apps.

For example, if I have an ApplicationController class that overrides init, is there an autorelease pool that gets created before it starts and gets drained after it ends?


回答1:


The main thread in an AppKit application runs an NSRunLoop to process events. NSRunLoop creates a new autorelease pool every time it processes a new event (or timer) and drains it once control flow has returned to the NSRunLoop. So in essence, every pass through the run loop has a fresh autorelease pool.



来源:https://stackoverflow.com/questions/4047647/autorelease-pools-in-appkit-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!