ERR_MEMORY : Not enough memory or resources

@cameron-fmod log
SystemNotInitializedException: [FMOD] Initialization failed : FMOD.Studio.System.create : ERR_MEMORY : Not enough memory or resources.
FMODUnity.RuntimeManager.get_Instance () (at Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs:114)
FMODUnity.RuntimeManager.PathToGUID (System.String path) (at Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs:905)
FMODUnity.RuntimeManager.CreateInstance (System.String path) (at Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs:918)
Drebot.LayerLocation.PlayStartMusic () (at Assets/[1]Source/Layers/LayerLocation.cs:69)

LayerLocation.cs:69 is
eventInstance = FMODUnity.RuntimeManager.CreateInstance(musicEvent);

and

SystemNotInitializedException: [FMOD] Initialization failed : FMOD.Studio.System.create : ERR_MEMORY : Not enough memory or resources.
FMODUnity.RuntimeManager.get_Instance () (at Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs:122)
FMODUnity.RuntimeManager.get_StudioSystem () (at Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs:128)
FMODUnity.RuntimeManager.AddListener (FMODUnity.StudioListener listener) (at Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs:335)
FMODUnity.StudioListener.OnEnable () (at Assets/Plugins/FMOD/src/Runtime/StudioListener.cs:18)

@DREBOTgs Do you have your Editor log? I feel like that may be more useful in tracking down the issue since the actual leak would happen well before the error occurs.

You can find it at %LOCALAPPDATA%\Unity\Editor\Editor.log on Windows.

1 Like

Not sure if it’s exactly the same issue, but one way this reliably happens to me is if I have Unity script changes set as “Stop Playing And Recompile”, and then during Play Mode I change something in a script.

That always results in FMOD grabbing more and more memory until I get the ERR_MEMORY message.

Thanks for the extra information, we have a fix planned for this coming in our next release.

1 Like

have you fixed this bug ?

Yes, the bug is fixed and will be released with 2.00.14 / 2.01.06 in the coming week.

Hi, is that really fixed?
I keep having to restart unity 2 or 3 times a day because of this.
I’m using 2.01.07 unity 2020.2.3f1

To our knowledge the FMOD_ERR_MEMORY error due to transitioning between play-in-editor and editor has been fixed. Can you provide some steps to reproduce it now?

If you create your own FMOD::System or FMOD::Studio::System using our C# API (not fetching ours via RuntimeManager), that may be a vector for this issue if you aren’t cleaning those objects up on transition.

I’m still very new to fmod but I think I’m using it pretty in a pretty simple way through components (fmod studio event emitter) and from code via: FMODUnity.RuntimeManager.PlayOneShot(StartQuestEventName);

Where StartQuestEventName is like this:

[FMODUnity.EventRef]
public string StartQuestEventName = "event:/SFX/UI/Objective";

Or this:

FMODUnity.RuntimeManager.StudioSystem.setParameterByName("Stealth", Level);

The only thing I did differently is for a typewriter effect where I tweak the pitch and volume:

void OnCharacter(char character)
    {
        if (Time.time - latestTimePlayed <= minSoundDelay)
            return; //Early return if not enough time passed yet

        //Plays audio
        eventState = FMODUnity.RuntimeManager.CreateInstance(EventName);
        eventState.setVolume(CurrentVolume);
        eventState.setPitch(CurrentPitch);
        eventState.start();
        
        
        // FMODUnity.RuntimeManager.PlayOneShot(EventName);
        latestTimePlayed = Time.time;
    }

All that usage is fine and shouldn’t cause any problems regarding the ERR_MEMORY issue. Could you detail steps for us to follow to cause the error you are seeing?

I’m sorry but as described in previous posts it happens after multiple times entering/leaving playmode.
I’d say between 20 and 30 times but I cannot replicate consistently. The last 2 days I completely disable the live play in editor and it seems that it’s occurring less often than before.
I understand that without a clear reproduce step you will not be able to investigate but next time it occurs I’ll send the stack trace

I have been trying to replicate this crash for the past few days with no success. I have attempted with Unity 2019.4 and Unity 2020.1 with FMOD Studio 2.01. Large Unity projects, small Unity projects, blank Unity projects, all have been entering and exiting PIE mode 30+ times each and no issues have been found.

I suspect there may be something specific in the game code being run in your instance that is preventing the FMOD system from being cleaned up properly, and re-entering PIE mode will create a new system instance.

If at all possible, could you please find a way to replicate this in a smaller project that you can send over? Even if it is not reproducible reliably, if it can occur in one project that you can send over, we can really hammer it to see what could be going wrong. Thanks for your patience with this difficult issue.

Just to add that this is happening to me on a regular basis.
I updated to FMOD 2.01.07 and running Unity 2019.4.7f1 but it still happens.
It happens after about 5 or 6 Play/Stop sessions pretty regularly. Sometimes the music just keeps playing and I can keep working in the editor but then once I press Play again, it will crash.

Is there a way to temporarily kill all Fmod instanced between play/stop?

Also if helpful, here is one of the many Editor.Log stack trace showing what is happening to FMOD:

========== OUTPUTTING STACK TRACE ==================

0x00007FFF6E11A6D0 (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E11A4DE (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E11AF91 (fmodstudioL) FMOD_Studio_VCA_SetVolume
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFF6E07C5D3)
0x00007FFF6E07C5D3 (fmodstudioL) (function-name not available)
0x00007FFF6E131348 (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E1320B0 (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E12CE6D (fmodstudioL) FMOD_Studio_VCA_SetVolume
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFF6E08BC43)
0x00007FFF6E08BC43 (fmodstudioL) (function-name not available)
0x00007FFF6E0FEFDF (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E116D1A (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E115220 (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E114F8C (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E11734A (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E1170EC (fmodstudioL) FMOD_Studio_VCA_SetVolume
0x00007FFF6E0BCB39 (fmodstudioL) FMOD::Studio::System::stopCommandCapture
0x00007FFF6E0BE24E (fmodstudioL) FMOD::Studio::System::stopCommandCapture
0x00007FFF6E0B7DB7 (fmodstudioL) FMOD::Studio::System::release
0x000001F225166BEA (Mono JIT Code) (wrapper managed-to-native) FMOD.Studio.System:FMOD_Studio_System_Release (intptr)
0x000001F225166A8B (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Plugins\FMOD\src\Runtime\wrapper\fmod_studio.cs:414] FMOD.Studio.System:release () 
0x000001F225166743 (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Plugins\FMOD\src\Runtime\RuntimeManager.cs:686] FMODUnity.RuntimeManager:OnDestroy () 
0x000001F226C4A1D8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFF6F34D690 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke 
0x00007FFF6F2D2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke 
0x00007FFF6F2DB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke 
0x00007FF77748FECE (Unity) scripting_method_invoke
0x00007FF777489C0D (Unity) ScriptingInvocation::Invoke
0x00007FF777489EDE (Unity) ScriptingInvocation::InvokeChecked
0x00007FF7774F1DE3 (Unity) SerializableManagedRef::CallMethod
0x00007FF777460FF9 (Unity) MonoBehaviour::WillDestroyComponent
0x00007FF7766960E0 (Unity) GameObject::WillDestroyGameObject
0x00007FF776EF90E0 (Unity) PreDestroyRecursive
0x00007FF776EF6977 (Unity) DestroyObjectHighLevel_Internal
0x00007FF776EF677E (Unity) DestroyObjectHighLevel
0x00007FF777487A2B (Unity) Scripting::DestroyObjectFromScriptingImmediate
0x00007FF7775E1031 (Unity) Object_CUSTOM_DestroyImmediate
0x000001F1B8E9BF07 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Object:DestroyImmediate (UnityEngine.Object,bool)
0x000001F1B8E9BDBB (Mono JIT Code) UnityEngine.Object:DestroyImmediate (UnityEngine.Object)
0x000001F225165CFB (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Plugins\FMOD\src\Runtime\RuntimeManager.cs:65] FMODUnity.RuntimeManager:get_Instance () 
0x000001F22516591B (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Plugins\FMOD\src\Runtime\RuntimeManager.cs:124] FMODUnity.RuntimeManager:get_StudioSystem () 
0x000001F225165693 (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Plugins\FMOD\src\Runtime\RuntimeManager.cs:382] FMODUnity.RuntimeManager:AddListener (FMODUnity.StudioListener) 
0x000001F225163233 (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Plugins\FMOD\src\Runtime\StudioListener.cs:20] FMODUnity.StudioListener:OnEnable () 
0x000001F226C4A1D8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFF6F34D690 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke 
0x00007FFF6F2D2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke 
0x00007FFF6F2DB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke 
0x00007FF77748FECE (Unity) scripting_method_invoke
0x00007FF777489C0D (Unity) ScriptingInvocation::Invoke
0x00007FF777453845 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007FF77745210E (Unity) MonoBehaviour::AddToManager
0x00007FF7774529FC (Unity) MonoBehaviour::AwakeFromLoad
0x00007FF775B99B2B (Unity) AwakeFromLoadQueue::InvokeAwakeFromLoad
0x00007FF775B93261 (Unity) AwakeFromLoadQueue::AwakeFromLoad
0x00007FF776AF5456 (Unity) AwakeAndActivateClonedObjects
0x00007FF776AF5F4D (Unity) CloneObject
0x00007FF7775E1BF0 (Unity) Object_CUSTOM_Internal_CloneSingle
0x000001F225162F5E (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Object:Internal_CloneSingle (UnityEngine.Object)
0x000001F225162B2B (Mono JIT Code) UnityEngine.Object:Instantiate<T_REF> (T_REF)
0x000001F2251613A3 (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Scripts\Managers\SceneLoader.cs:111] SceneLoader/<DoInitSequence>d__22:MoveNext () 
0x000001F225160C51 (Mono JIT Code) UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
0x000001F225160E40 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr (object,intptr,intptr,intptr)
0x00007FFF6F34D690 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke 
0x00007FFF6F2D2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke 
0x00007FFF6F2DB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke 
0x00007FF77748FECE (Unity) scripting_method_invoke
0x00007FF777489C0D (Unity) ScriptingInvocation::Invoke
0x00007FF77744C15F (Unity) Coroutine::Run
0x00007FF77745ED2C (Unity) MonoBehaviour::TryCreateAndRunCoroutine
0x00007FF77745E02B (Unity) MonoBehaviour::StartCoroutineManaged2
0x00007FF7775DF557 (Unity) MonoBehaviour_CUSTOM_StartCoroutineManaged2
0x000001F225160999 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.MonoBehaviour:StartCoroutineManaged2 (UnityEngine.MonoBehaviour,System.Collections.IEnumerator)
0x000001F225160583 (Mono JIT Code) UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
0x000001F22515F683 (Mono JIT Code) [G:\Conundrum\gameV3\Assets\Scripts\Managers\SceneLoader.cs:97] SceneLoader:Start () 
0x000001F226C51EB8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFF6F34D690 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke 
0x00007FFF6F2D2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke 
0x00007FFF6F2DB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke 
0x00007FF77748FECE (Unity) scripting_method_invoke
0x00007FF777489C0D (Unity) ScriptingInvocation::Invoke
0x00007FF777458E1C (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
0x00007FF777458F48 (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
0x00007FF777454959 (Unity) MonoBehaviour::DelayedStartCall
0x00007FF776AFAFF8 (Unity) DelayedCallManager::Update
0x00007FF776F2FB8F (Unity) `InitPlayerLoopCallbacks'::`2'::EarlyUpdateScriptRunDelayedStartupFrameRegistrator::Forward
0x00007FF776F199D8 (Unity) ExecutePlayerLoop
0x00007FF776F19AAD (Unity) ExecutePlayerLoop
0x00007FF776F1ECEC (Unity) PlayerLoop
0x00007FF7752CC3CC (Unity) PlayerLoopController::UpdateScene
0x00007FF7752B526D (Unity) PlayerLoopController::EnterPlayMode
0x00007FF7752C7925 (Unity) PlayerLoopController::SetIsPlaying
0x00007FF7752CA602 (Unity) Application::TickTimer
0x00007FF775C34EEE (Unity) MainMessageLoop
0x00007FF775C3F128 (Unity) WinMain
0x00007FF778C3B4B2 (Unity) __scrt_common_main_seh
0x00007FFFC7AA7034 (KERNEL32) BaseThreadInitThunk
0x00007FFFC9082651 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

Any updates on this? Or a way to temporarily avoid this issue?

As mentioned previously, we’ve unfortunately been unable to replicate it here. The stacktrace you’ve provided can’t tell us much without some internal debugging. Are you able to share the project this happens in?

Is there a way in the meantime that I can just force kill the Runtime managers that are getting instantiated?

Unfortunately, it’s not easy to share the project.
I do have my own custom ‘Editor’ version of FMOD (copied from EditorUtils.cs) that is being initialized on Load and maybe that is the culprit?
Here is the file, would love it if you could look at it. It was working fine until I updated FMOD to the latest version.Editor_FMODPreviewer.txt (4.8 KB)

Just to add, I commented it out and the problem still persists. This is REALLY frustrating and making it practically impossible to work. Any help would be very appreciated. I have a ton of crash logs if that helps in any way.

I’ve been informed that if you wish to use your own editor with FMOD you have to remove the system initializer and let the underlying Editor take care of it. Could you please try this and let me know if it helps?

Thanks for the update.

I completely removed my custom Editor and the issue persists.

But if I was to do that, would it be correct to make EditorUtils.cs a public class so I can access the FMOD.Studio.System?