Skip to content

Nil out the onStart callback after using it #1570

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 1 commit into from
Feb 27, 2023

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Feb 27, 2023

Motivation:

The ClientTransport has an onStart callback which is called once the stream has been established. For async calls this is used to notify the writability manager that it may now start writing. The callback references the call which holds the transport which holds the callback forming a strong retain cycle and a slow memory leak. The transport should break this cycle.

Modifications:

  • nil out the onStart callback after it has been called.

Result:

Fixes a leak

Motivation:

The `ClientTransport` has an `onStart` callback which is called once the
stream has been established. For async calls this is used to notify the
writability manager that it may now start writing. The callback
references the call which holds the transport which holds the callback
forming a strong retain cycle and a slow memory leak. The transport
should break this cycle.

Modifications:

- nil out the `onStart` callback after it has been called.

Result:

Fixes a leak
@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Feb 27, 2023
Copy link
Collaborator

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

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

Awesome fix! Thanks so much!

@glbrntt
Copy link
Collaborator Author

glbrntt commented Feb 27, 2023

The main-nightly failure is swiftlang/swift#63934

@glbrntt glbrntt merged commit 1f87e8c into grpc:main Feb 27, 2023
@glbrntt glbrntt deleted the gb-on-start-retain-cycle branch February 27, 2023 18:25
WendellXY pushed a commit to sundayfun/grpc-swift that referenced this pull request Aug 24, 2023
Motivation:

The `ClientTransport` has an `onStart` callback which is called once the
stream has been established. For async calls this is used to notify the
writability manager that it may now start writing. The callback
references the call which holds the transport which holds the callback
forming a strong retain cycle and a slow memory leak. The transport
should break this cycle.

Modifications:

- nil out the `onStart` callback after it has been called.

Result:

Fixes a leak
pinlin168 pushed a commit to sundayfun/grpc-swift that referenced this pull request Aug 24, 2023
Motivation:

The `ClientTransport` has an `onStart` callback which is called once the
stream has been established. For async calls this is used to notify the
writability manager that it may now start writing. The callback
references the call which holds the transport which holds the callback
forming a strong retain cycle and a slow memory leak. The transport
should break this cycle.

Modifications:

- nil out the `onStart` callback after it has been called.

Result:

Fixes a leak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants