Is correct to use GC.Collect(); GC.WaitForPendingFinalizers();?

前端 未结 6 1953
南笙
南笙 2020-12-02 17:03

I\'ve started to review some code in a project and found something like this:

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

Those lines usua

6条回答
  •  青春惊慌失措
    2020-12-02 17:42

    I've used this just once: to clean up server-side cache of Crystal Report documents. See my response in Crystal Reports Exception: The maximum report processing jobs limit configured by your system administrator has been reached

    The WaitForPendingFinalizers was particularly helpful for me, as sometimes the objects were not being cleaned up properly. Considering the relatively slow performance of the report in a web page - any minor GC delay was negligible, and the improvement in memory management gave an overall happier server for me.

提交回复
热议问题