0
0

I’m having a nasty memory leak everytime I play a 3D sound. If I have the following code commented out, the leak goes away. Otherwise, I lose a few K every second. Eventually, it starts to be quite significant. Also, I did call “FMOD::Memory_Initialize(ptr, len, NULL, NULL, NULL);” with a 5 Meg chunk of RAM before I created the FMOD sound system pointer, but this didn’t seem to help at all.

[code:55vp4old]
soundPtr->setDefaults(
44100, // hertz
_volumes[tSoundManager::kEffects],
0.0f,
128);

soundPtr->set3DMinMaxDistance(10.0f, 100.0f);

_systemPtr->playSound(
FMOD_CHANNEL_FREE,
soundPtr,
true,
&_soundRecords[availableSoundRecordIndex].channelPtr);

fmod_position.x = soundPosition.x;
fmod_position.y = soundPosition.y;
fmod_position.z = soundPosition.z;
_soundRecords[availableSoundRecordIndex].channelPtr->set3DAttributes(
&fmod_position,
NULL);

_soundRecords[availableSoundRecordIndex].channelPtr->setPaused(false);
[/code:55vp4old]

The _soundRecords is a fixed array of 20 records that I use to make sure I don’t play more than 20 sounds at once. As a sound completes, I make the entry available for the next sound. Also, I’m not running out of sound slots.

Is there some kind of known memory leak with FMOD Ex?

Thanks!

Bobby Thurman

  • You must to post comments
0
0

I think I found out where my memory leak was. It’s my fault of course, but I misunderstood the documentation.

I don’t have to free any channels. In fact, you can only stop them anyways?

I DO have to free my sound objects. I wasn’t doing this previously.

That’s it? Right? I won’t have any more memory leaks?

Bobby Thurman

  • You must to post comments
0
0

Sweet, I just re-wrote my sound manager wrapper to keep a sound name/pointer map. That way, I re-use the same sound object until I quit my game. Now, all my sound memory leaks are gone!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.