Not signed in
Copyright © 2026 Unity Technologies
Put the following script in the Spaceship Demo asset:
https://github.com/Unity-Technologies/SpaceshipDemo
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using Unity.Collections; #if UNITY_EDITOR [InitializeOnLoad] 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() { if(EditorApplication.isPlaying) { EditorApplication.ExitPlaymode(); } else EditorApplication.EnterPlaymode(); } } #endif
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:
https://unity.slack.com/archives/C3H8JSB5E/p1699316406804749
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.
Sign in to see your voted issues