Search Issue Tracker
By Design
Votes
0
Found in
2017.4.0f1
2017.4.6f1
Issue ID
1126514
Regression
No
GC.Collect occasionally fails to clean everything, resulting in Memory leakage on Players and in Editor
When Memory is allocated, the total Memory value is printed and that Memory is freed and cleaned with "GC.Collect". However, occasionally, the GC will fail to clean up the freed Memory, resulting in a Memory Leak.
To reproduce:
1. Download attached project “MemoryLeak.zip" and open in Unity
2. Open "MemoryLeak" scene
3. Enter to Play mode
4. Print "Activate Incremental Memory Loop" button in Game window
5. Look towards the Console, there can be 2 printouts:
1. Log 'Loop # Memory Before: # After GC: #' - This means no memory leak has occurred this frame
2. Warning 'Loop # Memory Before: # After GC: # Memory loss: #' - This means memory has either leaked or regained. If the number is positive, then a memory leak has occurred
Expected results: GC.Collect would clean up all freed Memory
Actual results: Sometimes GC.Collect fails to clean Memory and a Leak occurs
Notes:
- This issue appears on Windows Standalone, macOS Standalone, iOS, and Android
- This issue also appears on Editor
- I attached Profiler results which show Memory Leak in Editor and Standalone (Mono)
Reproduced on Unity 2017.4.0f1, 2017.4.20f2, 2018.3.6f1, 2019.1.0b3 and 2019.2.0a6
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
- Custom ScriptableObject asset in the project setting are not well deserialized during the Reimport All process
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
Resolution Note:
The test script allocates larger and larger managed arrays. These larger and larger sizes require new blocks to be allocated from OS for GC to fulfill. Eventually the available memory for the process will be exhausted.