Search Issue Tracker

In Progress

Fixed in 2023.3.0b3, 2024.1.0a1

Under Consideration for 2022.3.X



Found in




Issue ID




[Linux][Memory leak] entering and exiting Playmode continuously leads to memory usage up and crash



Put the following script in the Spaceship Demo asset:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Unity.Collections;


public class NewBehaviourScript
static NewBehaviourScript(){
EditorApplication.update += Update;
// Start is called before the first frame update
void Start()
NativeLeakDetection.Mode = NativeLeakDetectionMode.Enabled;

// Update is called once per frame
static void Update()


This will let the editor enter and exit playmode constantly. Observe from the system monitor that the memory Unity process takes keeps increasing.

Looking in the editor log, the memory consumption each time entering and exiting playmode also climbs up:

AcceleratorClientConnectionCallback - disconnected - :0
Unloading 54 Unused Serialized files (Serialized files now loaded: 0)
Loaded scene 'Temp/__Backupscenes/0.backup'
Deserialize: 11.782 ms
Integration: 159.701 ms
Integration of assets: 0.018 ms
Thread Wait Time: -0.003 ms
Total Operation Time: 171.498 ms
Unloading 1126 unused Assets / (2.4 MB). Loaded Objects now: 10094.
Memory consumption went from 1.11 GB to 1.11 GB.
Total: 37.907034 ms (FindLiveObjects: 2.505118 ms CreateObjectMapping: 1.130139 ms MarkObjects: 24.541882 ms DeleteObjects: 9.724916 ms)

attached half of the editor log here and looking from the bottom up you can see that the memory consumption has been consistently going up. This eventually goes to 30GB running for a day and crash. Looking at the system log, the program is killed by oom killer on linux.

Another issue with the memory profiler that is related to this:

On MacOS, the memory does not leak by entering/exiting playmode, but it does when using the memory profiler. As you could see in the snapshot, unity is claiming 60+GB memory when 4 memory snapshot and the rest is deleted.

All the incremental memory size seems coming from the native Malloc(Persisten) according to the profiler result.

  1. Resolution Note (fix version 2024.1.0a1):

    the PR landed and nightly tests with my script shows the memory leak is gone after this change.

  2. Resolution Note (fix version 2023.3.0b3):

    i ran my script overnight and the memory consumption is very consistent now. looks like the issue is gone after this fix. Thanks so much.

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.