Skip to content

Commit

Permalink
fix: networklist editor memory leak (#3147)
Browse files Browse the repository at this point in the history
* fix

This fixes the issue with NetworkLists on in-scene placed NetworkObjects causing small memory leaks when entering and exiting playmode.

* update

adding change log entry

* style

removing white spaces

* style

removing added CR/LF entries.

* update

adding PR number to log entry
  • Loading branch information
NoelStephensUnity authored Dec 3, 2024
1 parent dfabbed commit d7df73b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

- Fixed issue where `NetworkList` properties on in-scene placed `NetworkObject`s could cause small memory leaks when entering playmode. (#3147)
- Fixed in-scene `NertworkObject` synchronization issue when loading a scene with currently connected clients connected to a session created by a `NetworkManager` started as a server (i.e. not as a host). (#3133)
- Fixed issue where a `NetworkManager` started as a server would not add itself as an observer to in-scene placed `NetworkObject`s instantiated and spawned by a scene loading event. (#3133)
- Fixed issue where spawning a player using `NetworkObject.InstantiateAndSpawn` or `NetworkSpawnManager.InstantiateAndSpawn` would not update the `NetworkSpawnManager.PlayerObjects` or assign the newly spawned player to the `NetworkClient.PlayerObject`. (#3122)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public NetworkList(IEnumerable<T> values = default,
}
}

~NetworkList()
{
Dispose();
}

/// <inheritdoc />
public override void ResetDirty()
{
Expand Down Expand Up @@ -624,8 +629,16 @@ public int LastModifiedTick
/// </summary>
public override void Dispose()
{
m_List.Dispose();
m_DirtyEvents.Dispose();
if (m_List.IsCreated)
{
m_List.Dispose();
}

if (m_DirtyEvents.IsCreated)
{
m_DirtyEvents.Dispose();
}

base.Dispose();
}
}
Expand Down

0 comments on commit d7df73b

Please sign in to comment.