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
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)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- EditorGUILayout.PropertyField foldout icon inside Vertical Layout Group has an incorrect indent when used with OnInspectorGUI()
- [Android] [iOS] "NullReferenceException: Object reference not set to an instance of an object" throws when entering the Play Mode/opening the application
- The Player freezes on load when building Web platform
- Animator "Conditions" tab breaks when the only Parameter is deleted and another one is created
- "Shader error in 'Universal Render Pipeline/Lit': maximum ps_5_0 sampler register index (16) exceeded" error thrown after a build is completed when the "LOD Cross Fade" parameter is enabled
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);
}
dbydby
Jan 23, 2025 06:07
Unity2022.3.17f1,2DAnimation is 9.1.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.