In general all objects having any interaction with unmanaged resources should be disposed. With the CoreServiceClient
(CS client) it's obvious and easy to do (see Tridion 2013 SP1 Core service timeout with frequent requests), however with the TopologyManagerClient
(TP client) it's not that straightforward. One difference is that the CS client is a "pure" WCF client which inherits from ClientBase
which implements the IDisposable
(see below),
public class SessionAwareCoreServiceClient : ClientBase<ISessionAwareCoreService>, ISessionAwareCoreService
public abstract class ClientBase<TChannel> : ICommunicationObject, IDisposable where TChannel : class
while the TP client is an OData (and not WCF) client which does not implement IDisposable
public class TopologyManagerClient : Microsoft.OData.Client.DataServiceContext
Technically speaking, saying that OData has no connection with WCF is incorrect:
OData Service using WCF Service. OData is a standardized protocol for creating and consuming data APIs. OData builds on core protocols like HTTP and commonly accepted methodologies like REST
So, having all this in mind, the question of disposing the TP client and how to do it should be approached from that direction, ie. should I, and if yes, how should I dispose an OData client, but if IIRC, you needn't.
IDisposable
see: stackoverflow.com/questions/20392508/…