Not all references are being released

Open
#26 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, unity
Domain
game-dev

Research direction

Start with Basic/ComponentReference/Assets/Scripts/ComponentReference.cs around line 31 and trace the GameObjectReady callback alongside the reported AssetReferenceComponent behavior. Verify whether releasing the supplied handle is correct and whether released references stop sticking around; done means the sample's loading and release behavior is confirmed or the needed correction is documented.

Written by the indexing model from the issue text.

Description

https://github.com/Unity-Technologies/Addressables-Sample/blob/05119a010bcf01f3d75a9fd03f1e0dd3ad5de874/Basic/ComponentReference/Assets/Scripts/ComponentReference.cs#L31

AsyncOperationHandle<TComponent> GameObjectReady(AsyncOperationHandle<GameObject> arg)
{
        var comp = arg.Result.GetComponent<TComponent>();
        return Addressables.ResourceManager.CreateCompletedOperation<TComponent>(comp, string.Empty);
}

Using the AssetReferenceComponent i see some references to things i have released still sticking around.
Adding this extra release here seems to allow things to load and the other references i was seeing are going away now.

AsyncOperationHandle<TComponent> GameObjectReady(AsyncOperationHandle<GameObject> arg)
    {
        var comp = arg.Result.GetComponent<TComponent>();
        Addressables.Release(arg);
        return Addressables.ResourceManager.CreateCompletedOperation<TComponent>(comp, string.Empty);
    }

Is this a correct fix?

Dominant language
C#
Stars
1.5k
Forks
303
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Unity-Technologies/Addressables-Sample

All issues in Unity-Technologies/Addressables-Sample

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.