### Motivation There is a memory leak that can be visible when there are many topics that are cycled through (created and deleted).
The problem resides in that the `DispatchRateLimiter` register itself as a listener on the policies cache, but it never unregister. This leaves the `DispatchRateLimiter` instance hanging around even when the topic is not used anymore in a broker. ### Modifications * Removed the individual registration. `policiesCache().registerListener()` was not meant to have many listeners (as in one per topic) but rather as a way for multiple subcomponents to piggyback on the watch notifications. More the CopyOnWriteList is not efficient for multiple add and remove. * Keep registration at broker service level and then just rely on topic instance to call the `onPoliciesUpdate()`. [ Full content available at: https://github.com/apache/pulsar/pull/2699 ] This message was relayed via gitbox.apache.org for [email protected]
