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
- Group Selection title text size is smaller in renaming than the actual font size
- Shader Graph validation errors are not pointing to the right implementation
- Rich Text is not correctly highlighted when searching through Debug Logs in the Console window
- Shader warning in 'Hidden/Core/DebugOccluder' thrown after building High Definition 3D Sample Template
- Audio Mixer “+” buttons overlap with UI when the Audio Mixer window layout is set to Horizontal
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.