Skip to content
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

Bugfix/fix turn unit test memory leak #626

Merged

Conversation

mutexd
Copy link
Contributor

@mutexd mutexd commented Nov 3, 2024

Fix cyclic dependencies in ChannelBind/Permission/Allocation.

  • They all have timer-callback mechanism which remove themselves from the map that are owned by AllocationManager. They use Arc<> pointing to parent and thus cyclic dependencies are created. We replace Arc<> with Weak<>.
  • We also change the parameter of constructor of Allocation so that the Weak is required when creating it. I would encourage this pattern instead of assigning it after the creation.

RUSTFLAGS="-Z sanitizer=leak" cargo test in turn/ice shows no sign of memory leak.

- Both structs have a timer-callback like mechanism to remove itself from the table which held by Allocation. In this case, cyclic dependency is created when the struct holds Arc<> pointing to the table owning it. We replace the Arc<> in the callback with Weak<>
- Allocation hold Arc<> to the table of Allocations owned by AllocationManager and thus creates the cyclic dependency. We replace it with Weak<> when pointing to parent
@rainliu rainliu merged commit 03237d0 into webrtc-rs:master Nov 3, 2024
4 of 5 checks passed
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.

2 participants