After repeated usage (play-exit-play) FMOD will fail, raising the ERR_MEMORY noted in the title. The number of play-exit-plays does not seem to be deterministic.
This seems to be related to making updates in Studio, saving and building, then testing them in Unity. Simply play-stop-play’ing Unity doesn’t cause a memory error. It only seems to happen when I’m going back and forth from Studio, updating a sound, adding new sounds, saving / building, then immediately testing it in Unity. A workflow loop I would hope is extremely common.
1 Install FMOD Studio + API 1.10.04
2 Open FMOD Studio
3 Open Unity
4 Load a sample project, perhaps the Unity 2D platformer sample.
5 Create project in Studio and save it
6 In Unity, adjust FMOD settings so that they point to the new project. Turn on Load all Event and Sample Data and Init.
7 In Studio, create a new 3D sound. Add modulation to Volume and Pitch. Adjust Master min & max distance to 150 - 2k
(I convert world units in Unity to pixels, so we need a long range for 3d sounds.)
8 Save the Studio project, then build with F7.
9 Switch back to Unity wire up your FMOD audio to your game. Such that audio is only executed via code, using PlayOneShot. Ensure some sounds are fired on start, ex. an initial landing sound for the hero.
10 In Studio, modify the sounds you are using in-game. Save, Build. Then switch back to Unity and play the game.
11 Repeat step 10, until you get the out of memory error.
Based on what I can see of your system, through the msg in the Unity console, you have a few integration / build phases with Unity.
1, Create FMod “System”
2, Create “Banks” from linked project
I just moved my Studio project’s location and tried to run the game (in the unity editor) after getting the Created FMod “system” message. This results in a whole whack of “bus not found errors”. I stop play and wait for a few seconds. I get the “created banks” message. I run the game again and everything works.
It seems that the overall integration with Unity is just not robust enough to handle running of a game while there is still FMod work to do. I’m not sure if this is just really hard to do or impossible. But the current model seems inevitably error prone.
Circling back to my original out of memory issue, b/c you guys don’t (or can’t) ensure everything is init’d and built before someone runs a game via the editor there are all sorts of ways I could imagine where things get messed up, result in allocation / error issues, and the bug I’m seeing. So I’m a little surprised you cannot repro the issue or find it a unique scenario.
This has been fixed by modifying the way we destroy FMOD Systems used in the Unity Editor and will be available in version 2.00.14 which is due to be released shortly (it is going through QA at the moment).