From db586e07972ea66ca2056d79335247bf01bc20a1 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 25 Apr 2025 10:49:33 -0500 Subject: [PATCH 1/3] fix: memory leak without domain reload playModeStateChanged never gets unsubscribed --- com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs index 0aec58612f..4db8e5c350 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs @@ -1303,6 +1303,9 @@ private void OnDestroy() { Singleton = null; } +#if UNITY_EDITOR + EditorApplication.playModeStateChanged -= ModeChanged; +#endif } // Command line options From b44446e3fc5f6cab57ea1b19798357efb641d172 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 25 Apr 2025 10:54:03 -0500 Subject: [PATCH 2/3] Update CHANGELOG.md --- com.unity.netcode.gameobjects/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index ea9b77f778..524ea5a8a4 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -16,6 +16,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed +- Fixed: Memory leaks when domain reload is disabled. (#3428) - Fixed issue where during a `NetworkObject`'s spawn if you instantiated, spawned, and parented another network prefab under the currently spawning `NetworkObject` the parenting message would not properly defer until the parent `NetworkObject` was spawned. (#3403) - Fixed issue where in-scene placed `NetworkObjects` could fail to synchronize its transform properly (especially without a `NetworkTransform`) if their parenting changes from the default when the scene is loaded and if the same scene remains loaded between network sessions while the parenting is completely different from the original hierarchy. (#3388) - Fixed an issue in `UnityTransport` where the transport would accept sends on invalid connections, leading to a useless memory allocation and confusing error message. (#3383) From db633d122c362a14e1c964d53750141a977846f5 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 25 Apr 2025 10:57:37 -0500 Subject: [PATCH 3/3] Update CHANGELOG.md --- com.unity.netcode.gameobjects/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 524ea5a8a4..3e911cfcdd 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -16,7 +16,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed -- Fixed: Memory leaks when domain reload is disabled. (#3428) +- Fixed memory leaks when domain reload is disabled. (#3428) - Fixed issue where during a `NetworkObject`'s spawn if you instantiated, spawned, and parented another network prefab under the currently spawning `NetworkObject` the parenting message would not properly defer until the parent `NetworkObject` was spawned. (#3403) - Fixed issue where in-scene placed `NetworkObjects` could fail to synchronize its transform properly (especially without a `NetworkTransform`) if their parenting changes from the default when the scene is loaded and if the same scene remains loaded between network sessions while the parenting is completely different from the original hierarchy. (#3388) - Fixed an issue in `UnityTransport` where the transport would accept sends on invalid connections, leading to a useless memory allocation and confusing error message. (#3383)