Unity // ERR_MEMORY - Not enough memory or resources

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.

The only way around this is to restart Unity.

OnDestroy() is called…

void OnDestroy()
{
    if (studioSystem.isValid())
    {
        studioSystem.release();
        studioSystem.clearHandle();
    }
    initException = null;
    instance = null;
    isQuitting = true;
}

… but isValid() is always false and thus the system doesn’t get released or cleared.

Following your script tutorials for Unity I don’t see any mention of having to explicitly init the system or get a handle to it

When FMOD isn’t out of memory everything runs find. According to the FMOD debug view I’m using 6MB of memory, for about 10 sounds (events).

I’m on the latest version of FMOD Studio and the Programming API. Using a Mac. And on Unity 5.1.

Any help is appreciated.

Do FMOD devs ever check this board?

I also sent a support email, but haven’t heard anything.

Is this normal?

We will be looking into your issue shortly and will get back to you soon.

Sometimes support can take up to a week, but it is normally quicker than that.

Q. What support service is provided with a Free Indie license? A. Support is provided through FMOD forums and via email with a 1 week response time.
https://fmod.com/licensing

Thanks.

Some additional context…

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.

Sorry, I’m having trouble reproducing this here. Can you tell me the version of FMOD you are using and list the steps you take to reproduce the issue?

Sure.

Repro:

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.

BTW, this seems to be related to these issues:

http://www.fmod.org/questions/question/err_memory-not-enough-memory-or-resources/
http://www.fmod.org/questions/question/fmod-breaks-after-running-9-times-in-unity-err_memory/

FWIW…

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.

Thanks Stephen, with your steps I was able to reproduce the issue.

I have added this as a task and will investigate further.

Has this problem been solved ? How did you solve it?

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).

@cameron-fmod In 2.00.14? Isn’t 2.01.05 out already? Asking as I am using 2.01.05 and I notice that Max Memory keeps going up.

2.00 is still receiving updates, the fix will be added in 2.01.06.