ZhouWeikuan / cocos2d

cocos2d for android, based on cocos2d-android-0.82, and now ported from cocos2d-iphone 0.99.4. The googlecode address is here: http://code.google.com/p/cocos2d-android-1/ . There are several demos to watch.
610 stars 291 forks source link

issue related to CCLable holding strong ref to texture #17

Open BMR11 opened 13 years ago

BMR11 commented 13 years ago

Hi, There was an issue like: "Eclipse's memory analyzer points out that GLResourceHelper.reloadMap is holding some CCLabel as hash values, which are considered strong references. The labels are too strongly referencing the textures."

In last update of cocos2d android CCLabel.java and CCTexture2D.java were changed. So is this issue solved now? Will CCLable leak memory now?

Thanks.

sourceBreaker commented 13 years ago

I had the same problem and i resolved this as follows:

public void cleanup() {

    stopAllActions();
    unscheduleAllSelectors();

    if (children_ != null)
        for (int i=0; i<children_.size(); ++i) {
            CCNode node = children_.get(i);
            node.cleanup();

            if(node instanceof CCLabel)
            {
                ((CCSprite)node).getTexture().releaseTexture(CCDirector.gl);
            }

        }
}

I am not sure that if this solution would work fine on latest cocos code as i am using older version ....