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

Memory leak in RpcClient #1168

Closed
JHahnHRO opened this issue Nov 24, 2023 · 2 comments
Closed

Memory leak in RpcClient #1168

JHahnHRO opened this issue Nov 24, 2023 · 2 comments
Labels

Comments

@JHahnHRO
Copy link
Contributor

Describe the bug

RpcClient must be given a Channel upon construction and if used in mandatory-mode, the constructor adds a ReturnListener to this channel. However, this listener is never removed. It should be removed in the close-method.

Reproduction steps

  1. Instantiate RpcClient in mandatory-mode.
  2. Publish an unrouteable RPC message with the client and catch the UnrouteableRpcRequestException.
  3. Close the RpcClient.
  4. Repeat 1.-3. using the same channel.

Observe that first there will be an exception, then there will be an exception and a log-warning, then an exception and two log-warnings, then an exception and three log-warnings and so on. The reason is that each new RpcClient adds its own ReturnListener. One of them throws the exception, the other log warnings, because they look up the returned message in the previous RpcClient's continuation maps.

The log messages are annoying, but more importantly, the listeners accumulate over time and live for as long as the channel stays open.

Expected behavior

Closing an RpcClient should clean up thoroughly, including the removal of the ReturnListener so that the channel may be reused.

Additional context

No response

@JHahnHRO JHahnHRO added the bug label Nov 24, 2023
@michaelklishin
Copy link
Member

@JHahnHRO please submit a PR.

@michaelklishin
Copy link
Member

Also note that this class is an example you can and should modify/build upon. But maybe that's exactly why we should make it clean any ReturnListeners it adds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants