B
benoit808
I don't have a lot of experience with C++ so I apologize if this is a
stupid question.
I use Paul Nettle's memory manager (mmgr.cpp) which reports a memory
leak but I don't think there's one. Here is the code (i took some stuff
out to simplify):
void myFunction()
{
Sprite *pImage;
sprintf(pStr, "s04-%02d.png", i);
pData = pFile->FindFile(pStr, &iSize);
pImage = new Sprite(GetD3DDevice(), pData, iSize, 330, 50);
pImage->DefineFrame(0, 0, 330, 25, 0);
pImage->DefineFrame(0, 25, 330, 25, 0);
pImage->SetAnimFrame(0);
Song *pSong = new Song(strdup(pStr), pImage);
}
The leak is reported on "Sprite *pImage". The pImage object passed to
the Song constructor is being released by the Song destructor. My
understanding is that the pImage pointer is released when myFunction()
exits. Since I do not delete the object before the pointer release, I
assume this is the reason why mmgr.cpp reports the leak.
Am I right or am I missing something?
Ben
stupid question.
I use Paul Nettle's memory manager (mmgr.cpp) which reports a memory
leak but I don't think there's one. Here is the code (i took some stuff
out to simplify):
void myFunction()
{
Sprite *pImage;
sprintf(pStr, "s04-%02d.png", i);
pData = pFile->FindFile(pStr, &iSize);
pImage = new Sprite(GetD3DDevice(), pData, iSize, 330, 50);
pImage->DefineFrame(0, 0, 330, 25, 0);
pImage->DefineFrame(0, 25, 330, 25, 0);
pImage->SetAnimFrame(0);
Song *pSong = new Song(strdup(pStr), pImage);
}
The leak is reported on "Sprite *pImage". The pImage object passed to
the Song constructor is being released by the Song destructor. My
understanding is that the pImage pointer is released when myFunction()
exits. Since I do not delete the object before the pointer release, I
assume this is the reason why mmgr.cpp reports the leak.
Am I right or am I missing something?
Ben