[fixed]memory leak in loadScene

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
gbox
Posts: 37
Joined: Mon May 01, 2006 3:41 am
Location: jeonju, korea
Contact:

[fixed]memory leak in loadScene

Post by gbox »

1.8.0 rev 3920

in loadScene Fuction , missing  ' file->drop(); '
it cause memory leak

i added file->drop();' after 'SceneLoaderList->loadScene(file, userDataSerializer, rootNode);'

Code: Select all

 
 
bool CSceneManager::loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer, ISceneNode* rootNode)
{
        bool ret = false;
 
        io::IReadFile* file = FileSystem->createAndOpenFile(filename);
 
        if (!file)
        {
                os::Printer::log("Unable to open scene file", filename.c_str(), ELL_ERROR);
                _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
                return false;
        }
 
        // try scene loaders in reverse order
        s32 i = SceneLoaderList.size()-1; 
        for (; i >= 0 && !ret; --i)
                if (SceneLoaderList[i]->isALoadableFileExtension(filename))
                {
                        ret = SceneLoaderList[i]->loadScene(file, userDataSerializer, rootNode);
 
                        file->drop(); // <-- may be it need? 
                }
 
        if (!ret)
                os::Printer::log("Could not load scene file, perhaps the format is unsupported: ", filename.c_str(), ELL_ERROR);
 
 
        _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
        return ret;
}
 
 
http://cafe.naver.com/jcga

professor of Jelabukdo Game Engine Academy
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [with fix]memory leak in loadScene

Post by hybrid »

Yeah, you're right. Fixed.
Post Reply