Search Issue Tracker
By Design
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
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
Resolution Note:
NativeQueue internally implements block caching mechanism that's used by all queues. The reason for memory bump is because on first use static method creates this pool of empty blocks, that are then used at later point.