Learn how to manage server agent object lifetimes in a Microsoft Lync Server 2013 deployment.
Managing server agent object lifetimes
The server agent maintains the lifetimes of several SIP-specific objects that are defined by classes in the Microsoft.Rtc.Sip namespace.
For example, when a transaction is terminated, the server agent releases not only the corresponding Transaction object, but also releases the Request object for that transaction and any associated Response objects.
This issue is independent of the garbage collection that the .NET Framework common language runtime (CLR) performs. All classes whose instances have controllable lifetimes implement the standard IDisposableinterface, which enables application control of the object lifetime that are independent of the CLR. Because many SIP objects such as transactions have no reason to persist after they are processed, reclaiming their resources immediately improves efficiency and performance. This occurs with a call from the server agent object to the implementation of the Close()method on the object whose resources must be deallocated.
The base implementation of Close()on the Transactionclass merely invokes a virtual implementation of the IDisposable.Dispose()method. Any class that extend the ServerTransaction or ClientTransaction instance can also override Close()with an application-specific implementation that extends the life of the transactions as needed.
Any overriding implementation of Close()must ensure that Dispose()is called after the event is processed or incur a possible performance penalty.