reactor / reactor-rabbitmq

Reactor RabbitMQ
Apache License 2.0
157 stars 55 forks source link

Shutdown listener added in Sender never get removed and can lead to memory leak when used together with channel pools #134

Closed frzme closed 4 years ago

frzme commented 4 years ago

Actual Behavior

https://github.com/reactor/reactor-rabbitmq/blob/v1.4.2.RELEASE/src/main/java/reactor/rabbitmq/Sender.java#L965 adds a Shutdown listener to the channel upon subscription of a sendWithPublishConfirms send. This shutdown listener is never removed.

When used together with Channel pooling the Channel objects are long lived and the shutdown listeners remain in memory. As the shutdown listeners reference the subscriptions they keep a lot of objects alive.

Possible Solution

In https://github.com/reactor/reactor-rabbitmq/blob/v1.4.2.RELEASE/src/main/java/reactor/rabbitmq/Sender.java#L1054 the confirmListener gets removed. It might be appropriate to also remove the shutdownListener.

acogoluegnes commented 4 years ago

Good catch and thanks for the analysis. A PR would be welcome.