Search Issue Tracker
Active
Under Consideration for 1.1.X
Votes
0
Found in [Package]
1.1.1
Issue ID
PROFB-266
Regression
No
Calling MemoryProfiler.TakeSnapshot repeatedly causes a memory leak
Reproduction steps:
1. Open the attached “LeakTest“ project
2. Open the “Assets/SampleScene.unity“ Scene
3. Change the path in the “Assets/LeakTest.cs“ Script to a valid path on your system (memory snapshots are going to be stored there)
4. Open the Build Settings (File > Build Settings)
5. Enable the Development Build checkmark and make sure the Scripting Backend is set to “IL2CPP“ in the Player Settings
6. Build and Run the project
7. Open the Memory Profiler (Window > Analysis > Memory Profiler)
8. Add the 1st and the 200th snapshot from the snapshots folder (path that you’ve set on the 2nd step)
9. Compare snapshots
Expected result: Memory usage between both snapshots should be similar. No tool's overhead (Memory Profiler) tagged as part of the game's
Actual result: There’s a visible increase in memory usage between the 2 snapshots. Memory Profiler specific memory is shown in the snapshot as the game's memory
Reproducible with: 1.1.1 (2022.3.51f1, {-}6000.0.24f1{-})
Couldn’t test with: 0.7.1-preview.1 (2021.3.45f1) - MemoryProfiler.TakeSnapshot doesn’t exist
Reproducible on: M1 Max MacOS 14.6.1
Not reproducible on: No other environment tested
Notes:
- -Using 6000.0.24f1 the issue is reproducible with Mono and IL2CPP.- With 2022.3.51f1 it’s only reproducible with IL2CPP.
- The speed between snapshots decreases the more snapshots are made, which shouldn’t be the case (only with IL2CPP)
- After debugging the leak, we found that the allocations originate from here: See LeakCallstack.png. It looks as though it's the memory capture itself that allocates. When adding breakpoints in code, I notice that some classes are initialized over and over, each time there is a new capture. E.g. the Awaiter class in my snapshot below: See Awaiter.png.
- On each call, the __klassIndex is different. E.g. both those are for Awaiter: See klassIndex.png
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- GPU utilization increases by 20% on Meta Quest headsets when Render Graph is enabled on 6000.0.16f1 and higher
- Value on Slider (Int) control in UI Builder displays as default when saving UI Document
- Color mismatch in UI Builders Library panel when the Editors theme is set to Light Mode
- [Android ] "AndroidJNI.ToBooleanArray" returns a random non-zero value instead of "IntPtr.Zero" when the method argument is null
- Non-HDR color picker opens when selecting material color with HDR enabled
Add comment