Can I force memory cleanup in C#?

后端 未结 5 608
执念已碎
执念已碎 2021-01-12 18:02

I heard that C# does not free memory right away even if you are done with it. Can I force C# to free memory?

I am using Visual Studio 2008 Express. Does that mat

5条回答
  •  逝去的感伤
    2021-01-12 18:30

    You can clean up your memory by given both methods:

    GC.Collect();
    GC.WaitForPendingFinalizers();
    

    Read both Reference GC.Collect() and GC.WaitForPendingFinalizers()

提交回复
热议问题