Page 1 of 1

Memory leak in createDevice? (Not a bug)

Posted: Sun Sep 10, 2006 8:32 pm
by alc
I have a larger application that runs fine. However, when the application terminates, VC reports a memory leak. Trying to find the cause of this, if learned that this happens even when the main function is reduced to

Code: Select all

int main()
{	
  IVideoDriver *driver;
  IGUIEnvironment *env;
  ISceneManager *smgr;

  GLOBAL::device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(800, 600),16,false,true);
return 0xFE;	
}
The FE return code is to help me make sure, that it is my own termination. I'm using svn 194 fresh this morning from the repository. Any thought on this? So far my app runs fine, so it is not critical for me. But a memory leak in createDevice is not a pleasant though altogether!

Posted: Sun Sep 10, 2006 9:57 pm
by Warchief
Call

Code: Select all

device->drop();
before app end.

It's like calling a "new" without "delete" to free memory.
From irrlicht help:
When you create an object in the Irrlicht engine, calling a method which starts with 'create', an object is created, and you get a pointer to the new object. If you no longer need the object, you have to call drop(). This will destroy the object, if grab() was not called in another part of you program, because this part still needs the object. Note, that you only need to call drop() to the object, if you created it, and the method had a 'create' in it.

Posted: Mon Sep 11, 2006 8:41 am
by alc
DOH!! My bad entirely!!

The latest svn started givin' me mem leaks, and it came from a missing ->drop() somewhere in my code, a miss that apparently didn't cause problems earlier. In my hast to isolate the problem, I forgot the most obvious ->drop of them all ... thanx!