C# (Sharp) Programming Language Question:

Is there a way to force garbage collection?

Tweet Share WhatsApp

Answer:

Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects destructed, and System.GC.Collect() doesn't seem to be doing it for you, you can force finalizers to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers().

Download C# (Sharp) Programming Language PDF Read All 163 C# (Sharp) Programming Language Questions
Previous QuestionNext Question
Is there regular expression (regex) support available to C# developers?Does C# support properties of array types?