rabbitmq / rabbitmq-objc-client

RabbitMQ client for Objective-C and Swift
https://rabbitmq.com
Other
242 stars 84 forks source link

Avoid RMQConnection leaks by adopting weak refs (on behalf of @BarryDuggan) #195

Closed michaelklishin closed 2 years ago

michaelklishin commented 2 years ago

for some important dependencies of allocated channels and RMQConnection itself.

In this client, RMQConnection auto-allocates a channel for the purpose of special "channel zero" (system communication in the protocol) purposes, and that leads to a loop of strong references that prevent RMQConnection instances from being released.

Contributed by @BarryDuggan in #194.

michaelklishin commented 2 years ago

This PR has a syntax error but also makes too many properties weak. The compiler warns of transport being released right after assignment, for example.

@BarryDuggan do you see the same warnings by any chance?

michaelklishin commented 2 years ago

This unintentionally dropped the delegate property in RMQConnection as well.

BarryDuggan commented 2 years ago

I didnt get any compiler warning related to transport. That said, when I remove weak from transport there is still no retain cycle. Additionally weak is not needed for heartbeatSender or channelZero either

In summary weak can be from: