3D Engine/Cocos2d-x

spine-cocos2dx leak (cocos2d-x 2.2.2)

BlueSwamp 2014. 5. 31. 10:50
반응형

spine을 사용하면

CCTextureCache::sharedTextureCache()->addImage() 로 추가된 이미지가

해제가 되지않아 메모리에서 제거 되지 않는다.

 

void _AtlasPage_createTexture (AtlasPage* self, const char* path) {
     CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(path);
     CCTextureAtlas* textureAtlas = CCTextureAtlas::createWithTexture(texture, 4);
     textureAtlas->retain();
     self->rendererObject = textureAtlas;
     self->width = texture->getContentSize().width;
     self->height = texture->getContentSize().height;
}

 

void _AtlasPage_disposeTexture (AtlasPage* self) {
     ((CCTextureAtlas*)self->rendererObject)->release();
}

_AtlasPage_disposeTexture에서 release() 하지만 retainCount()가 2여서 지워 지지 않는다.

임시로 아래 두 줄을 추가하여 내려 지워준다.

void _AtlasPage_disposeTexture (AtlasPage* self) {
      CCTexture2D* texture = ((CCTextureAtlas*)self->rendererObject)->getTexture();
     CC_SAFE_RELEASE( texture );
      ((CCTextureAtlas*)self->rendererObject)->release();
}

 

 

 

반응형