Page 1 of 1

AnimationSystem memory leaks???

Posted: Thu Dec 09, 2010 08:14
by wang37921
hi ce~
i'm not sure, is this cegui's memory leaks..
But, i has exclude my code step by step..finally find when i add blow code will bring memory leaks..

Code: Select all

   CEGUI::AnimationManager& animMgr = CEGUI::AnimationManager::getSingleton();
   animMgr.loadAnimationsFromXML("GuiFuncBtns.xml");


I am a green hand~so i'm not sure this is right. .waiting for your answer.. :oops:
so, i go into cegui code page, and find many about animationsystem's class, they don't clear their members..
like:

Code: Select all

//----------------------------------------------------------------------------//
void Animation::destroyAffector(Affector* affector)
{
    AffectorList::iterator it =
        std::find(d_affectors.begin(), d_affectors.end(), affector);

    if (it == d_affectors.end())
    {
        CEGUI_THROW(InvalidRequestException(
                        "Animation::destroyAffector: Given affector not found!"));
    }

    d_affectors.erase(it);
}

//----------------------------------------------------------------------------//

and

Code: Select all

//----------------------------------------------------------------------------//
void AnimationManager::destroyAnimation(const String& name)
{
    AnimationMap::iterator it = d_animations.find(name);

    if (it == d_animations.end())
    {
        CEGUI_THROW(UnknownObjectException(
            "AnimationManager::destroyAnimation: Animation with given name not "
            "found."));
    }

    Animation* animation = it->second;
    destroyAllInstancesOfAnimation(animation);

    d_animations.erase(it);
    delete animation;
}

Re: AnimationSystem memory leaks???

Posted: Thu Dec 09, 2010 08:19
by wang37921
sorry~void AnimationManager::destroyAnimation(const String& name),has delete anim~
destroyAnimationInstance, havn't deleted animInst...

Code: Select all

//----------------------------------------------------------------------------//
void AnimationManager::destroyAnimationInstance(AnimationInstance* instance)
{
    AnimationInstanceMap::iterator it =
        d_animationInstances.find(instance->getDefinition());

    for (; it != d_animationInstances.end(); ++it)
    {
        if (it->second == instance)
        {
            d_animationInstances.erase(it);
            return;
        }
    }

    CEGUI_THROW(InvalidRequestException(
        "AnimationManager::destroyAnimationInstance: Given animation instance "
        "not found."));
}

Re: AnimationSystem memory leaks???

Posted: Thu Dec 09, 2010 12:34
by Kulik
Thanks and kudos! Good catch :) . I have fixed both mem leak bugs for 0.8 in svn r2745. I will backport them to 0.7 if necessary (I am not sure if there will be any more 0.7 minor releases but it's likely).

Re: AnimationSystem memory leaks???

Posted: Fri Dec 10, 2010 00:23
by Jamarr
Please post in the appropriate sub-forum, as this keeps threads organized and avoids cluttering sub-forums with unrelated content. It's not that hard. Thanks.

Re: AnimationSystem memory leaks???

Posted: Fri Dec 10, 2010 02:05
by wang37921
Jamarr wrote:Please post in the appropriate sub-forum, as this keeps threads organized and avoids cluttering sub-forums with unrelated content. It's not that hard. Thanks.

my english is poor, so sorry for that, i will try my best to do that... :(