如何在c#中显式使用垃圾收集器 [英] How to use garbage collector explicitly in c#
本文介绍了如何在c#中显式使用垃圾收集器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请有人告诉我如何实现垃圾收集器并在c#中使用它。在此先感谢
Please can anyone tell me how to implement the garbage collector and use it in c#. Thanks in advance
推荐答案
使用 GC.Collect [ ^ ]
请注意,这样做的理由很少。操作成本高,评估所有收集对象;它是阻塞的,让你的程序的其余部分等待;如果代码是针对一次性接口编写的,那么真正资源匮乏的系统没有任何区别。
Use GC.Collect[^]
Note that there are very little good reasons to do this. The operation is costly, evaluating all objects for collection; it is blocking, making the rest of your program wait; and except for really resource starved systems makes no difference if the code is written respecting disposable interfaces.
这篇关于如何在c#中显式使用垃圾收集器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文