Here's a small test-program to reproduce it:
Code: Select all
// addVolumeLightSceneNode not releasing static mesh when removed.
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
int main(int argc, char *argv[])
{
IrrlichtDevice * Device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640,480) );
if (!Device)
return false;
scene::ISceneManager* smgr = Device->getSceneManager();
gui::IGUIEnvironment* guiEnv = Device->getGUIEnvironment();
video::IVideoDriver* videoDriver = Device->getVideoDriver();
while ( Device->run() )
{
if ( Device->isWindowActive() )
{
// LeakHunter can be enabled in IrrCompileConfig.h
// irr::core::array<const IReferenceCounted*> refBefore = LeakHunter::getReferenceCountedObjects();
// std::cout << "before: " << refBefore.size() << "\n";
irr::scene::IVolumeLightSceneNode* vlightnode = smgr->addVolumeLightSceneNode( 0, -1, 100, // Subdivisions on U axis
100, // Subdivisions on V axis
video::SColor(0, 255, 255, 255), // foot color
video::SColor(0, 0, 0, 0)); // tail color
videoDriver->beginScene(true, true);
smgr->drawAll();
guiEnv->drawAll();
videoDriver->endScene();
vlightnode->remove();
// irr::core::array<const IReferenceCounted*> refAfter = LeakHunter::getReferenceCountedObjects();
// std::cout << "after: " << refAfter.size() << "\n";
}
Device->sleep( 1 );
}
Device->closeDevice();
Device->drop();
// irr::core::array<const IReferenceCounted*> refEnd = LeakHunter::getReferenceCountedObjects();
// std::cout << "end: " << refEnd.size() << "\n";
return 0;
}
Now there is one workaround that would probably work - removing the meshbuffer from the videodriver when the node is removed. But for some reason none of the nodes with meshbuffer ever seem to do that for static meshes - so not sure right now if anything speaks against that. And certainly the better solution would be if meshbuffers remove themself on destruction - but I guess they miss the access to the videodriver.
Also - IVolumeLightSceneNode should maybe give access to the Mesh - probably could be derived from IMeshSceneNode. Then users could work around this at least.
I'm not deep enough into the hardwarebuffer stuff to feel comfortable to fix this myself without some feedback ...