11 December 2013
版权声明:本文基于署名 2.5 中国大陆许可协议发布,欢迎转载,演绎或用于商业目的,但是必须保留本文的署名elloop(包含链接)

#AutoReleasePool

##concepts

  • PoolManager singleton, holds a stack of AutoReleasePool*.
    • push(): push a new AutoReleasePool into top.
    • pop(): pop a AutoReleasePool, clear the pool. (when stack’s size > 1), called every frame in CCDisplayLinkDirector::mainLoop().
  • AutoReleasePool holds an array of CCObject(Ref)*, clear() will release each obj.

##initialization&finalization

  • PoolManager created by sharedPoolManager(), first called in CCDirector’s init() finalized in CCDirector’s destructor, by calling purgePoolManager()

  • AutoReleasePool created by PoolManager::push(). deleted by PoolManager::pop().

##main method AutoReleasePool - addObject(): put obj into m_pManagedObjectArray



分享到