Copyright © 2026 Unity Technologies
Memory address leaks when using Visual Elements in a specific project
Reproduction steps:
1. Open the attached project "ReproProj"
2. Open the "/Assets/Scenes/SampleScene.unity" Scene
3. Enter the Play Mode
4. Open Memory Profiler (Window > Analysis > Memory Profiler)
5. Click "Capture"
6. Select the captured snapshot
7. Open "All Of Memory" tab
8. Find the cleared out Visual Elements under Managed > Managed Objects > UnityEngine.UIElements.VisualElement
9. On the right side of the Memory Profiler window, observe the references to the Visual Element
Reproducible with: 6000.3.0a1, 6000.1.9f1
Could not test with: 2022.3.62f1, 6000.0.51f
(Assets\Scripts\Main\UIDisplay\VisualElements\InfographicPanel.cs(11,63): error CS0117: 'Color' does not contain a definition for 'gray1')
Reproducible on:
Play Mode
Testing environment: Windows 10 Enterprise 21H2
Not reproducible on: No other environment tested
Alternative reproduction steps:
1. Create a project
2. Add an UIDocument to the Hierarchy
3. Attach the "HudManager.cs" script to the UIDocument (script attached below)
4. (optional) Change the UIDocuments, Panel Settings Scale Mode to "Scale With Screen Size"
5. Save the scene
6. Build and run the project, with "Development Build" toggled on
7. Follow the original steps from step 4, but attach the Memory Profiler to the Player
Expected result: Cleared out and/or unparented VisualElements do not linger in memory due to being referenced by the UI Renderer or callbacks
Actual result: Cleared out and/or unparented VisualElements do not linger due to references to them.
Reproducible with: 6000.3.0a1, 6000.1.9f1
Not Reproducible with: 2022.3.62f1
Notes:
The issue is NOT that the Memory Profiler falsely lists the VisualElements Status as "Bug: Liveness Reason Unknown" with the Hint text"There is no reference pointing to this object and no GCHandle reported for it. This is a Bug, please report it using 'Help > Report a Bug' and attach the snapshot to the report." is present. That bug is tracked as PROFB-351
The Reference Panel clearly lists references to these Visual Elements, the Memory Profiler UI just has a logic error in it where it assumes the Ref Count needs to match the listed references, or otherwise there needs to be a GCHandle pointing at the object. However, the references list simply does not list repeated references from the same managed object, confusing the logic that sets the status. The liveness reason is very much that there are valid references to this managed object.
Issues you vote on will appear here