void Ref::release(){
--_referenceCount;
if (_referenceCount == 0){
delete
this
;
}
}
|
Ref* Ref::autorelease()
{
PoolManager::getInstance()->getCurrentPool()->addObject( this);
return
this
;
}
|
void DisplayLinkDirector::mainLoop(){
// 省略一部分代码
{
drawScene();
// release the objects
PoolManager
::getInstance()->getCurrentPool()->clear();
}
}
|
void AutoreleasePool::clear()
{
for
(
const
auto
&obj : _managedObjectArray)
{
obj->release();
}
_managedObjectArray.clear();
}
|
relealse | autorelease |
直接对object进行引用计数减1,并且当引用为0时将对象析构。 | 将对象放入AutoreleasePool中,并且当当前帧结束时对放入的object进行release操作。 |