Skip to content

Server interceptors retain cycle #1559

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 3, 2023
Merged

Server interceptors retain cycle #1559

merged 1 commit into from
Feb 3, 2023

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Feb 3, 2023

Motivation:

There's a code path through the ELF-based server handlers where the interceptor pipeline does not get nil'd out to break the reference cycle between the handler and the interceptors leading to a leak. This can happen if the RPC ends unexpectedtly.

Modifications:

  • Break the retain cycle on the next event-loop tick; this gives any clean up code a chance to run first.
  • Break the retain cycle from the interceptors when they send end.

Results:

Fewer leaks.

@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Feb 3, 2023
Motivation:

There's a code path through the ELF-based server handlers where the
interceptor pipeline does not get `nil`'d out to break the reference
cycle between the handler and the interceptors leading to a leak. This
can happen if the RPC ends unexpectedtly.

Modifications:

- Break the retain cycle on the next event-loop tick; this gives any
  clean up code a chance to run first.
- Break the retain cycle from the interceptors when they send end.

Results:

Fewer leaks.
@glbrntt glbrntt merged commit 3f7c714 into grpc:main Feb 3, 2023
WendellXY pushed a commit to sundayfun/grpc-swift that referenced this pull request Aug 24, 2023
Motivation:

There's a code path through the ELF-based server handlers where the
interceptor pipeline does not get `nil`'d out to break the reference
cycle between the handler and the interceptors leading to a leak. This
can happen if the RPC ends unexpectedtly.

Modifications:

- Break the retain cycle on the next event-loop tick; this gives any
  clean up code a chance to run first.
- Break the retain cycle from the interceptors when they send end.

Results:

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

There's a code path through the ELF-based server handlers where the
interceptor pipeline does not get `nil`'d out to break the reference
cycle between the handler and the interceptors leading to a leak. This
can happen if the RPC ends unexpectedtly.

Modifications:

- Break the retain cycle on the next event-loop tick; this gives any
  clean up code a chance to run first.
- Break the retain cycle from the interceptors when they send end.

Results:

Fewer leaks.
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