Loading FileHeaders too slow

My game runs at about ~50 FPS, but I’m seeing huge spikes whenever I load something.
Most of the computation goes to the process “Loading.LoadFileHeaders”.


I think my problem is related to the way I load the assets. I’m using addressables, and bassically I want to load a random sound that matches a number of labels, say for example I have 5 possible audios for when you win a combat and I want to choose one at random. The labels may be [“player”, “combat”, “win”].
To do this, I use the code below, wich probably loads all of the audio and generates the spikes when doing that:

    public IEnumerator LoadRandomAudioClip (List<AssetLabelReference> labels, AudioSource source)
    {

        #region > Checks

        if (labels == null || labels.Count < 0) { Debug.LogWarning ($"Guarda, pediste un audo al azar pero la lista de etiquetas que pasaste no tenía nada."); yield break; }
        if (source == null) { Debug.LogWarning ($"Source era NULL"); yield break; }


        #endregion

        //We load all the addresses with the labels you requested
        AsyncOperationHandle<IList<IResourceLocation>> soundsHandleList = Addressables.LoadResourceLocationsAsync (labels, Addressables.MergeMode.Intersection);

        //While loading, wait...
        while (soundsHandleList.Status == AsyncOperationStatus.None) { yield return null; }

        //If the list is not valid or it haven't found any results return.
        if (!soundsHandleList.IsValid () || soundsHandleList.Result.Count < 1) { Debug.LogWarning ($"Pediste un sonido con una serie de etiquetas que ningún sonido tiene, volviendo"); yield break; }

        //From the list of possibles sounds choose one at random.
        IResourceLocation audioAddress = soundsHandleList.Result[Random.Range (0, soundsHandleList.Result.Count)];

        //We remove the list of sounds from memory.
        Addressables.Release (soundsHandleList);

        //Load the address
        yield return StartCoroutine (LoadAddressableAudio (audioAddress, source));

    }

    private IEnumerator LoadAddressableAudio (IResourceLocation audioAddress, AudioSource source)
    {
        //We load the selected audio.
        AsyncOperationHandle<AudioClip> audioHandle = Addressables.LoadAssetAsync<AudioClip> (audioAddress);

        //We wait till the audio has loaded
        while (audioHandle.Status == AsyncOperationStatus.None) { yield return null; }

        //We put the audio  in the audio source and we run it.
        Debug.Log ($"We load the audio {audioHandle.Result.name}");
        source.clip = audioHandle.Result;
        source.Play ();


        //We wait till the audio is finished
        while (source.isPlaying) { yield return null; }

        //Once the audio is finished we remove it from the audio source
        source.clip = null;

        //We relese the handle of the audio
        Addressables.Release (audioHandle);
    }

File IO is slow. I’m not sure what your goal here is, with releasing the resources immediately after using them, but you definitely want to preload as many resources as possible – either in a loading screen or slowly in the background before they’re needed – and definitely avoid loading half a dozen just to pick one at a random and then unload them all immediately afterwards.

I’m still trying to figure out how to handle the memory and the resources. The goal of loading and unloading them after I’ve used them was to have as few resouces loded into memory as possible. I thought you could get them on demand fast, and then unload them after having used them to free the memory. Currently it seems I’m using a bit too much memory and so I thought this was a good practice.
Also, I wasn’t sure I was loading everything to randomly pick one element, it wasn’t my intention. I thought I was only handling the addresses, not loading the whole thing. I just realeased that list in case I was wrong. Could you by any change suggest a better method to do it without loading them to guide me?
So, I guess what I should do then is pre load every sound related to the characters that are on this scene and have them available in memory till they die or exit the scene.
I’m still a bit puzzled of why loading a file stops the execution, since it’s an async operation, I thought that it wouldn’t have any effect, since it would spread the loading overhead into many frames. Recently I learn about the options in the Quality settings like “Async Upload Time Slice” and the buffer, and I’m experimenting with that, but it’s only for texture and meshes. Any guidance would be appreciated.