jgauffin / griffin.networking

Networking library for .NET
http://blog.gauffin.org/2012/05/griffin-networking-a-somewhat-performant-networking-library-for-net/
GNU Lesser General Public License v3.0
108 stars 35 forks source link

DigestAuthenticator should implement IDisposable #28

Open highfield opened 10 years ago

highfield commented 10 years ago

The DigestAuthenticator class in the HTTP project should implement IDisposable in order to dispose the NonceService (the inside Timer). As long the Timer is running a strong reference will keep the instance alive. In this way, new DigestAuthenticator instances will leak memory. I'd also consider to expose the IDisposable interface to the HttpService, for the dispose chain. Because the not-so-comfortable disposal of instances, another solution might be to have a centralized clock source (i.e. singleton), then turn any NonceService as a weak-observer of this source.

The example as in may lead to memory leaks: https://github.com/jgauffin/griffin.networking/blob/master/Source/Protocols/Http/Griffin.Networking.Protocol.Http.DemoServer/Basic/MyHttpService.cs