The AssetBundle 'Memory' can't be loaded because another AssetBundle with the same files is already loaded

Hello, I’m working on a Unity project where I have two asset bundles containing different scenes. When I click the level 1 button, it should load the asset bundle scene for level 1, and so on for level 2. But when I go back to the main menu and reopen level 1, it gives me an error message: The AssetBundle ‘Memory’ can’t be loaded because another AssetBundle with the same files is already loaded. Does anyone know how to resolve it?

IEnumerator LoadSceneFromBundle(string bundleUrl, string sceneName)
    {
        if (!remoteAssetBundle)
        {
            using (WWW web = new WWW(bundleUrl))
            {

                yield return web;

                if (!string.IsNullOrEmpty(web.error))
                {
                    Debug.LogError("Failed to download AssetBundle from " + bundleUrl + "! Error: " + web.error);
                    yield break;
                }

                remoteAssetBundle = web.assetBundle;
            }
   

            if (remoteAssetBundle.isStreamedSceneAssetBundle)
            {
                string[] scenePaths = remoteAssetBundle.GetAllScenePaths();
                foreach (var path in scenePaths)
                {
                    Debug.Log("Scene in bundle: " + path);
                }

                SceneManager.LoadScene(sceneName);
            }
            else
            {
                Debug.LogError("Asset Bundle does not contain scenes!");
            }
        }
    }

I have little experience with asset bundles but it sounds like it’s trying to tell you that you already have that level 1 bundle loaded. You didn’t unload it I presume?

You likely need to either unload each bundle when switching levels or check if the bundle is already loaded, and if so, just load the scene not the bundle containing the scene.

I believe this is one of the things that Addressables address, not having to keep taps on what bundle is loaded and which isn’t.

how to unload each bundle properly?

Try using Networking.UnityWebRequestAssetBundle.GetAssetBundle, there is some documentation there talking about caching of AssetBundles.

And yes you have to track AssetBundles that you open so that you can reuse the already open ones, and eventually unload them when you don’t need them anymore.

This error usually occurs when the same AssetBundle is loaded into memory more than once, even if the file paths are different.

A few things you may want to check:

  • Are you mixing Addressables and manual AssetBundle.LoadFromFile()?
  • Are you loading the same bundle under different names?
  • Is UnityWebRequestAssetBundle caching involved?
  • Does the bundle hash differ between builds?

Also, make sure the previous bundle is properly unloaded using Unload(false) or Unload(true) before attempting to load it again.

In most cases, this is not a memory leak but a duplicate bundle load conflict.