5
Reply

How to invoke garbage collector programmatically in c# ?

Hussain Ahmed

Hussain Ahmed

10y
2.9k
0
Reply

    MyBigMemoryClass instance = GetMyInstance(); // Do something with instance instance = null; // Unroot this, so there are (hopefully) no references to it left GC.Collect(); // Collect everything

    Using finalize or dispose

    Mr.Hussain is right

    Mr.Hussain is right

    Call garbage collector programmatically, use code “ GC.Collect(); “