Interviews3 answers
Is there a way to force garbage collection?
3 Answers
GC.Collect();
Keerthi VenkatesanPosted Apr 21, 2016, 9:55 PM EDT
GC.Collect();
Pramod VermaPosted Jan 24, 2015, 9:06 AM EST
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().
nikhil kansalPosted Jul 14, 2006, 3:24 AM EDT

