Hi,
We’ve been struggling with an apparent memory leak for a while now and as much as I investigate I just can’t find where it is, all instances eventually get correctly removed. This ‘leak’ becomes specially apparent when using our internal automatic testing system that plays the game at a high speed, so lots of sounds can sometimes pile up (but not to infinity, I monitored the number of events and it never kept on going up).
We use FMOD 2.01.05 on a custom engine PC and PS4 game. FMOD Studio is also used. Our initialization looks like this:
FMOD::Studio::System *m_soundSystem;
FMOD::Studio::System::create(&m_soundSystem);
FMOD::System *lowLevelSoundSystem;
m_soundSystem->getCoreSystem(&lowLevelSoundSystem);
lowLevelSoundSystem->setSoftwareFormat(48000, FMOD_SPEAKERMODE_STEREO, 2);
m_soundSystem->initialize(128, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL | FMOD_INIT_VOL0_BECOMES_VIRTUAL, NULL);
FMOD_ADVANCEDSETTINGS settings = {};
settings.cbSize = sizeof(FMOD_ADVANCEDSETTINGS);
owLevelSoundSystem->getAdvancedSettings(&settings);
settings.vol0virtualvol = .001f;
lowLevelSoundSystem->setAdvancedSettings(&settings);
FMOD::Studio::Bank *m_bank;
m_soundSystem->loadBankMemory((const char*)MicroROM::dget("soundbank.bank"), MicroROM::sget("soundbank.bank"), FMOD_STUDIO_LOAD_MEMORY_POINT, FMOD_STUDIO_LOAD_BANK_NORMAL, &m_bank);
Other than investigating and making sure (to the best of my knowledge) that FMOD is being used correctly, I tried doing a couple things to try to get more information:
-
On one hand I ran the test using the FMOD debug libraries and it seems the AsyncCommandBuffer keeps on having to increase in size for some reason and eventually fails. For some reason this always happens around the 350MB mark even if my system has a lot of spare memory. I pasted the whole debug ouput to this hackmd link in case there’s some important piece of information in there: https://hackmd.io/7lPGS5dmTIKH7DPeG1yAMw
-
On another hand I made sure there were no obvious leaks by attaching a session of FMOD Live and checked that instances weren’t growing up against my will. I can confirm that after several hours the memory usage has increased and yet the values on “Voices (Self)”, “Lifespans” and “Instances (Self)” have been kept more or less constant (some are even lower at the time of checking, but that’s probably just due to there being less sounds playing at this moment). I’m assuming that if I was incorrectly leaking instances or any stuff FMOD-related this is were it would show (please correct me if I’m wrong).
I’m assuming my usage of FMOD is what’s causing these issues, but is there any document or any hint that someone can give me to see if I spot what the culprit is?
Thanks in advance. Please, let me know if there’s any other piece of information that would be helpful.