Skip to content

fix: Memory leak in UnityTransport after StartClient failure#2518

Merged
simon-lemay-unity merged 4 commits intodevelopfrom
fix/utp-leak-client-failure
Apr 19, 2023
Merged

fix: Memory leak in UnityTransport after StartClient failure#2518
simon-lemay-unity merged 4 commits intodevelopfrom
fix/utp-leak-client-failure

Conversation

@simon-lemay-unity
Copy link
Copy Markdown
Contributor

If StartClient failed, then the driver would not be created. But if the driver is not created, we exit early in Shutdown which prevents us from disposing of the network settings and send queue (if any). This would result in a memory leak. The fix is simply to always dispose of these resources in Shutdown, without guarding it with a check on the driver.

One simple way to trigger that memory leak would be to start a client with an invalid IP address.

Changelog

  • Fixed: Fixed a memory leak in UnityTransport that occurred if StartClient failed.

Testing and Documentation

  • Includes unit test.
  • No documentation changes or additions were necessary.

@simon-lemay-unity simon-lemay-unity requested review from a team as code owners April 19, 2023 15:19
@simon-lemay-unity simon-lemay-unity enabled auto-merge (squash) April 19, 2023 15:20
Copy link
Copy Markdown
Member

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
I thought I had added a test for the client failing with a bad address... but glad you caught that!
👍

@simon-lemay-unity simon-lemay-unity merged commit e651438 into develop Apr 19, 2023
@simon-lemay-unity simon-lemay-unity deleted the fix/utp-leak-client-failure branch April 19, 2023 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants