WeakReference is used in Funq to track IDisposable
's that's stored in a WeakReference Stack of disposables as seen here. Basically Funq tracks every IDisposable
WeakReference created so they can all be disposed of when the Container is disposed.
I would first look at whether you could reduce your use of IDisposable
instances (e.g. using more singletons), otherwise try modifying the Funq source code to use Stack<IDisposable>
instead of a Stack<WeakReference>
and let me know if this resolves your issue, if it does I can include an opt-in option in ServiceStack to use Stack<IDisposable>
instead of Stack<WeakReference>
.