I am using a Singleton instance created from a nested class. This instance contains several static collections that are cleared when Singleton is deleted, but the problem is that I get a link to a non-zero remote singleton that is not properly garbage collected.
I would like to know WHEN AND HOW to completely dispose and garbage collect my Singleton instance, so when the instance is requested again after dispose (and set to null), a new instance is created.
I use the following nested template for a Singleton instance:
public class SingletonClass : IDisposable { private List<string> _collection; private SingletonClass() { } public static SingletonClass Instance { get { return Nested.Instance;
The problem in line 1 is that after removing SingletonClass from the client class, the _collection object becomes null, while the SingletonClass instance remains non-empty even after setting = null.
source share