Code-Sharp/WampSharp

Event handler leak when cancel an invocation

bigbearzhu opened this issue · 0 comments

Hi @darkl,

Just noticed another leak, but this one is event handler leak when we have lots of RPC calls cancelled. You can try run CallerDealerTests.LeakTestOnCancelCalls from this demo branch

The issue is that every time WampCalleeInvocationHandler.Cancel is called, it creates a temporary WampRpcOperationCallback to get a potential existing WampRpcInvocation. However in WampRpcOperationCallback constructor it connects mMonitor.ConnectionClosed and this event handler is never removed. I'm thinking it probably should not connect in constructor or we will need a different type for the key in the mCallbackToInvocation dictionary that only takes in Session and RequestId from WampRpcOperationCallback.

image