From 6da8ec80a361f659dc5280b0012fbbc6efd6ddd6 Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 11 Sep 2024 22:22:46 +0200 Subject: [PATCH] fix: NetworkIdentity.OnDestroy cyclic memory leak --- Assets/Mirror/Core/NetworkIdentity.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index f4cfcfe42..746dd483d 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -682,6 +682,11 @@ void OnDestroy() // fixes: https://github.com/MirrorNetworking/Mirror/issues/3324 NetworkClient.spawned.Remove(netId); } + + // workaround for cyclid NI<->NB reference causing memory leaks + // after Destroy. [Credits: BigBoxVR/R.S.] + // TODO report this to Unity! + this.NetworkBehaviours = null; } internal void OnStartServer()