0
0

I’ve recently implemented the FMOD::Memory_Initialize() function call with wrappers into our own alloc/realloc/free memory management functions. I discovered by doing that that sounds created with System::Create() are not freed when you do a System::release(), and that you have to do a Sound::release() explicitly.

Which is fine; I just didn’t know that before now 😀

However, once I implemented code to release() all of the Sound objects, there still remained one nasty memory leak reported at the end through the sound memory callback wrappers. This memory leak I tracked down to some incorrect data in our sound file reference, which was building an invalid filename. The line looks like this:
[code:19104ddt]
FMOD_RESULT res = sgpSystem->createSound(szFile, FMOD_MODE(nMode), NULL, &pSound);
if(res != FMOD_OK)
{
if(pSound)
{
pSound->release();
}
// Show a data warning, continue the loop, etc.
}
[/code:19104ddt]

Now, when szFile contains a legitimate path, this allocates the memory for pSound and then I store off the resulting pointer and release it later on in life. However, when szFile is NOT a valid file, res gets set to FMOD_ERR_FILE_NOTFOUND, pSound remains NULL, but some memory is still allocated! Specifically, there is a 2064-byte allocation happening somewhere in there.

So, to summarize, I’m using FMOD::Memory_Initialize() with alloc/realloc/free, calling System::createSound() with an invalid filename such that it returns file not found, and there are 2064 bytes left over.

So, there it is. Thank you!

Guy Somberg
Audio Programmer

  • You must to post comments
0
0

No, it probably isn’t — that little bit of code I put in while trying to track this problem down. The original didn’t have the pSound->release() on failure.

Thanks, though! I’ll remove the offending piece of code, and assure the other programmers that the memory leak will go away with a new version.

  • Guy
  • You must to post comments
0
0

Whoops! You’re right!

Turns out the system I did this on is running 4.00.28! Oops. 😳 I thought I’d already converted it.

I’ll upgrade this computer over the weekend and retest.

I’m sorry for the inconvenience.

  • Guy
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.