UIButton Memory Leak

UIButton appears to be leaking memory for me. More specifically _titleRenderer’s retain in Button::setTitleLabel() doesn’t have a matching release.

Removing the retain from Button::setTitleLabel() appears to fix the issue.

Is there a reason retain is being called on _titleRenderer even though it’s being added as a child?

void Button::setTitleLabel(Label* label)
{
    if (_titleRenderer != label) {
        CC_SAFE_RELEASE(_titleRenderer);
        _titleRenderer = label;
        CC_SAFE_RETAIN(_titleRenderer);

        addProtectedChild(_titleRenderer, TITLE_RENDERER_Z, -1);
        updateTitleLocation();
    }
}