Skip to content

fix: Memory leak in UnityTransport after StartClient failure #2518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 19, 2023

Conversation

simon-lemay-unity
Copy link
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
Collaborator

@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