Search Issue Tracker

In Progress

Under Consideration for 7.1.X, 9.1.X, 10.1.X

Votes

0

Found in [Package]

7.1.2

9.1.3

10.1.4

Issue ID

DANB-793

Regression

No

Memory leak when a GameObject with a Sprite Skin component is deleted

Package: 2D Animations

-

Reproduction steps:
1. Open the attached “IN-91239” project
2. Build and Run the Player
3. Open the Memory Profiler
4. Take a memory snapshot
5. In the Player, click on “CreateAndDelete100”
6. After 30 seconds, take second memory snapshot
7. Compare memory snapshots
8. Select “All of Memory” tab and search for “Leaked”
9. Observe the memory allocations

Expected result: No “Leaked Managed Shell” Transform objects found
Actual result: Multiple (2 for each Sprite Skin component deleted, in this case - 200) “Leaked Managed Shell” Transform objects

Reproducible with: 7.1.2(2021.3.47f1), 9.1.3 (2022.3.55f1), 10.1.4 (6000.0.33f, 6000.1.0b1)

Reproducible environments: Windows 11 (24H2)
Not reproducible environments: No other environments tested

Reproducible with these devices:
VLNQA00591 - samsung Galaxy S23 (SM-S911B), CPU: Snapdragon 8 Gen 2 (SM8550), GPU: Adreno 740, OS: 14

Note: Not reproducible in the editor

Comments (3)

  1. dbydby

    Jan 23, 2025 06:59

    If you do not manually destroy SpriteSkin when destroying GameObject, or if you destroy SpriteSkin in the same frame, it will cause a memory leak. If you destroy SpriteSkin and then delay destroying GameObject for one frame, it will not cause a memory leak. Why is this?

    public GameObject ObjPrefab;

    // Start is called before the first frame update
    void Start()
    {
    StartCoroutine(Create());
    }

    private IEnumerator Create()
    {
    yield return new WaitForSeconds(2);
    GameObject ObjFish = GameObject.Instantiate(ObjPrefab);
    ObjFish.transform.SetParent(this.transform);
    yield return new WaitForSeconds(2);
    Destroy(ObjFish.GetComponent<UnityEngine.U2D.Animation.SpriteSkin>());
    yield return null;
    GameObject.DestroyImmediate(ObjFish);
    }

  2. dbydby

    Jan 23, 2025 06:07

    Unity2022.3.17f1,2DAnimation is 9.1.3.

  3. dbydby

    Jan 23, 2025 06:05

    I have also encountered a similar situation. If a prefab is instantiated and the prefab contains a SpriteSkin component, even if the object is destroyed, searching for leaks in the memory profiler will still find a reference to SpriteSkinUpdateHelper.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.