# After close and stop sound, FMOD failed to initialise again by "FMOD::System\_Create(&system)"

**URL:** <https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519>\
**Category:** FMOD Engine\
**Tags:** ios\
**Created:** [August 3, 2021, 8:03am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519 "2021-08-03T08:03:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![surfmike](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@surfmike](https://qa.fmod.com/u/surfmike)\
**Post date:** [August 3, 2021, 8:03am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/1 "2021-08-03T08:03:10Z")

</div>

After close and stop sound when we quickly initialising FMOD again by using “FMOD::System\_Create(&system)”, it gives an error “FMOD\_ERR\_MEMORY”.

Can you please look into this issue and let me know what is going wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [August 4, 2021, 4:48am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/2 "2021-08-04T04:48:36Z")

</div>

[FMOD\_ERR\_MEMORY](https://www.fmod.com/resources/documentation-api?version=2.02&page=core-api-common.html#fmod_err_memory) means not enough memory or resources. In the context of `FMOD::System_Create`, this error arises if you have run out of physical memory or if you have more than 8 system objects. If you are calling System\_Create multiple times then I suspect it’s because you have more than 8 system objects, but on a memory constrained environment such as mobile it’s feasible you could be running out of physical memory.  
Are you calling `release()` on your system objects before attempting to create new systems with `FMOD::System_Create`?  
If you could please provide me with your FMOD version and a reproduction or code sample of what you are doing when the error occurs then I can look into the issue further.

---

<div class="post-metadata">

**Author:** ![surfmike](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@surfmike](https://qa.fmod.com/u/surfmike)\
**Post date:** [August 4, 2021, 9:09am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/3 "2021-08-04T09:09:42Z")

</div>

> [@surfmike](#):
>
> “FMOD\_ERR\_MEMORY”

Hi, I am sharing some piece of code below, some time it work and return “FMOD\_OK” but when I am quick start sound again after shut down, it doesn’t work.  
One more thing I want to add that “releaseSound” and “releaseSystem” doesn’t effect result at all.

```
Common_Init(&extradriverdata);
/*
 Create a System object and initialize.
*/

[self releaseSound];
[self releaseSystem];
    result = FMOD::System_Create(&system); //This line return “FMOD_ERR_MEMORY”
     if (result == FMOD_OK){
    ERRCHECK(result);

  result = system->getVersion(&version);
  ERRCHECK(result);

```

FMOD\_VERSION 0x00020010

Thanks.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [August 6, 2021, 4:28am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/4 "2021-08-06T04:28:13Z")

</div>

Thank you for the additional information. I haven’t been able to reproduce any errors by emulating your example, can you please include your method definitions for `releaseSound` and `releaseSystem`?  
One other thing I am curious about- why do you need to release and create a new System object here? Can you continue to use the existing System object without releasing it and immediately creating a new one?

---

<div class="post-metadata">

**Author:** ![surfmike](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@surfmike](https://qa.fmod.com/u/surfmike)\
**Post date:** [August 9, 2021, 10:07am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/5 "2021-08-09T10:07:56Z")

</div>

```auto
-(void)releaseSound {
    if(sound)
    {
        result = sound->release();
        ERROR_CHECK(result);
        sound = 0;
    }
}

-(void)releaseSystem {
    if(system)
    {
        result = system->close();
        ERROR_CHECK(result);
        
        result = system->release();
        ERROR_CHECK(result);
    }
}

```

Above is the whole code for `releaseSound` and `releaseSystem` functions.

I need to create new system here to play set and play sound again after shut down and close.

Am I doing something wrong here?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [August 11, 2021, 2:34am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/6 "2021-08-11T02:34:12Z")

</div>

Are you creating a new system every time you play a sound? I am just trying to think of why you would need to release the system and then create a new one instead of storing it for the lifetime of the application and releasing it just before the application closes.  
Have you tried adding a short call to [sleepForTimeInterval](https://developer.apple.com/documentation/foundation/nsthread/1413673-sleepfortimeinterval?language=objc) before calling `FMOD::System_Create` and seeing if that affects the result?

---

<div class="post-metadata">

**Author:** ![tienthuan05082002](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@tienthuan05082002](https://qa.fmod.com/u/tienthuan05082002)\
**Post date:** [March 26, 2023, 11:07pm UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/7 "2023-03-26T23:07:36Z")

</div>

I’m experiencing a similar issue, but there are no errors during the initialization of fmod and sound playback. Here’s my code:

```auto

JNIEnv *mEnv = env;
int code = 0;
code = System_Create(&system_);
LOGI("playAiSound-%s-%d", "System_Create", code)
bool isPlaying = true;
jclass cls;
jmethodID methodid;
const char *path_cstr = mEnv->GetStringUTFChars(path, nullptr);
LOGI("playAiSound-%s", path_cstr)
try {
    cls = (env)->FindClass("dev/keego/voice/fmodsound/bridge/SoundPlayUtil");
    methodid = (env)->GetStaticMethodID(cls, "onInitSound", "()V");
    (env)->CallStaticVoidMethod(cls, methodid);
    system_->init(32, FMOD_INIT_NORMAL, nullptr);
    // Create sound
    code = system_->createSound(path_cstr, FMOD_LOOP_NORMAL, nullptr, &sound_);
    LOGI("playAiSound-%s-%d", "createSound", code)
    if (path != nullptr) {
        mEnv->ReleaseStringUTFChars(path, path_cstr);
    }
    code = system_->playSound(sound_, nullptr, false, &channel_);
    LOGI("playAiSound-%s-%d", "playSound", code)
    methodid = (env)->GetStaticMethodID(cls, "onPlaySound", "()V");
    (env)->CallStaticVoidMethod(cls, methodid);
    unsigned int length = 0;
    sound_->getLength(&length, FMOD_TIMEUNIT_MS);
    LOGI("playAiSound-%d", length)

} catch (...) {
    LOGE("playAiSound-%s", "play error!")
    code = 1;
    goto end;
}
while (isPlaying) {
    usleep(100);
    channel_->isPlaying(&isPlaying);
}
LOGI("playAiSound-%s", "play over！")
goto end;
end:

code = sound_->release();
LOGI("playAiSound-%s-%d", "release sound！", code);
code = system_->close();
LOGI("playAiSound-%s-%d", "close system！", code);
code = system_->release();
LOGI("playAiSound-%s-%d", "release system！", code);
methodid = (env)->GetStaticMethodID(cls, "onComplete", "()V");
(env)->CallStaticVoidMethod(cls, methodid);
return code;

```

Here’s the logcat:

```auto
2023-03-27 05:57:11.472 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-System_Create-0
2023-03-27 05:57:11.472 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-/storage/emulated/0/Music/VoiceChanger/1679844887938.wav
2023-03-27 05:57:11.522 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-createSound-0
2023-03-27 05:57:11.522 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-playSound-0
2023-03-27 05:57:11.522 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-14293
2023-03-27 05:57:11.586 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-play over！
2023-03-27 05:57:11.586 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-release sound！-0
2023-03-27 05:57:11.598 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-close system！-0
2023-03-27 05:57:11.598 3890-4056 FmodSound dev.keego.voice.changer I playAiSound-release system！-0

```

````auto

Upon closer inspection, my program is getting stuck in the following loop:

```cpp
while (isPlaying) {
    usleep(100);
    channel_->isPlaying(&isPlaying);
}

````

At this point, no sound is being played by the system.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 30, 2023, 3:40am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/8 "2023-03-30T03:40:29Z")

</div>

This questions will be answered in this forum post: [https://qa.fmod.com/t/after-closing-and-stopping-sound-fmod-fails-to-play-audio-when-quickly-reinitializing/2002](https://qa.fmod.com/t/after-closing-and-stopping-sound-fmod-fails-to-play-audio-when-quickly-reinitializing/2002)

---

<div class="post-metadata">

**Author:** ![tli47](https://avatars.discourse-cdn.com/v4/letter/t/f17d59/32.png) [@tli47](https://qa.fmod.com/u/tli47)\
**Post date:** [June 18, 2024, 8:56am UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/9 "2024-06-18T08:56:02Z")

</div>

Hi, @jeff_fmod @Connor_FMOD  
In my case, I have a sound card that connects some audio devices those numbers are more than 8. In my previous solution, I created multiple ‘system’ instance that binds a related device, however, I met ‘FMOD\_ERR\_MEMORY’. The reason you mentioned above(8 is maximum limit that fmod could support).

My question is how to handle my case, if the audio device number is over 8? Any idea?

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 20, 2024, 11:44pm UTC](https://qa.fmod.com/t/after-close-and-stop-sound-fmod-failed-to-initialise-again-by-fmod-system-create-system/17519/10 "2024-06-20T23:44:28Z")

</div>

Hi,

Unfortunately, 8 is a hard limit for FMOD systems.
