Search Issue Tracker

Active

Votes

0

Found in

2022.3.61f1

6000.0.47f1

6000.1.0f1

6000.2.0a9

Issue ID

UUM-103862

Regression

No

UnsafeUtility.Malloc uses 4MB when creating an empty NativeQueue

-

How to reproduce:
1. Open the attached "IN-98674" project
2. Open the "test" scene
3. Navigate to the project directory and run the "test1.exe" (found in "IN-98674/Builds/test1")
4. In the "test1" window, press the Spacebar
5. Go to “Open Memory Profiler > Capture New Snapshot“
6. Select the captured snapshot
7. Navigate to “All of Memory > Native > Unity Subsystems > UnsafeUtility > Malloc (Persistent)”
8. Observe the “Allocated Size” value

Expected result: Malloc (Persistent) uses around 1.3-1.5KB of memory (similar to other native collections)
Actual result: Malloc (Persistent) uses 4.0MB of memory

Reproducible with: 2022.1.0a10, 2022.3.61f1, 6000.0.47f1, 6000.1.0f1, 6000.2.0a9
Could not test with: 2021.3.51f1 (different Memory Profiler UI made it difficult to locate the Malloc (Persistent) value)

Reproducible on: macOS 15.3 (M4), Windows 11 (by user)
Not reproducible on: No other environments tested

Notes:
- The “Test.cs“ script, attached to the “Main Camera” GameObject in the Hierarchy window, creates and deletes a NativeQueue when the Spacebar is pressed
- Reproducible with IL2CPP and Mono Scripting Backend
- The “GC Allocated In Frame” value in the Profiler window shows different results when creating a NativeQueue. With IL2CPP Scripting Backend, Windows shows 11.4 KB while MacOS shows 8.0 KB. With Mono Scripting Backend, Windows shows 2.2 KB while MacOS shows 2.5 KB
- a NativeQueue uses 4.0 MB of memory, while NativeList uses 1.3 KB, and NativeArray uses 1.5 KB

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.