derekcollison/nats — Issue #30: auto unsubscribe can make memory leak
Author: joonilkim
Created: 2012-01-20 01:33:59+00:00
State: open

Hi, Im Kim

While i was testing Cloudfoundry, I found some memory leak. Its from NATS client.

Cloudfoundry cc sends msg via NATS client's request method with max expected response. Because having max expected response, NATS client sets it to auto unsubscribe. It makes work well for NATS server.. It will remove the subscribtion when its reponses hits expected number.. But NATS client is not.. Although hit its expected response, it do not try to remove that subscription... So number of subscriptions grows in the client... it makes cc's memory leak..

If you put below codes before the end of on_msg method, it no longer makes any leak.. But Im not sure if it is proper location..

def on_msg
....
unsubscribe(sid) if (sub[:max] && (sub[:received] >= sub[:max])) # if auto unsubscribe, cancel subscription.
end

I expected public patch for it from next release..

Thanks..