The problem is, the memory usage increased each time I re-create irrlicht Device. I found out that the font objects and textures have not been removed. I can remove another texture using the method removeAllTextures() in IVideoDriver, but I can't remove the font texture. How should I solve it? Is there a way to remove the texture being used by an object of IGUIFOnt? Or can I set the previously loaded font texture to the new re-created GUI skin?
My code is below.
Code: Select all
void CGameManager::init()
{
irrlichtDevice = createDevice(driverType, screenSize, depth,
fullscreen, shadows, vsync, 0);
irrlichtDevice->run();
irrlichtDevice->setEventReceiver(this);
// the problem is here. They are all gui::IGUIFont
font = irrlichtDevice->getGUIEnvironment()->getFont("resources/images/fontgaramond12.bmp");
fontLabel = irrlichtDevice->getGUIEnvironment()->getFont("resources/images/fontgaramond12.bmp");
bigfont = irrlichtDevice->getGUIEnvironment()->getFont("resources/images/fontgaramond18.bmp");
if (!font)
irrlichtDevice->getGUIEnvironment()->getSkin()->setFont(font);
}
Code: Select all
irrlichtDevice->closeDevice();
init();