简体   繁体   English

.NET垃圾收集器在单独的线程中?

[英].NET Garbage Collector in a separate Thread?

Is it possible to run the garbage collection in a separate thread? 是否可以在单独的线程中运行垃圾回收? So that it dosent block the main Thread of the process? 这样就不会阻塞进程的主线程吗?

Yes, however there are some configurations where you can run it in the background automagically. 是的,但是有一些配置可以在后台自动运行。

see this article on the Garbage Collection process . 有关垃圾回收过程,请参见本文。 https://msdn.microsoft.com/en-us/library/ee787088(v=vs.110).aspx https://msdn.microsoft.com/zh-CN/library/ee787088(v=vs.110).aspx

后台GC已经在单独的线程上发生-这就是为什么它是“后台”的原因-但是GC生命周期的一部分必须阻塞该进程中的所有线程(而不仅仅是主线程)才能完成-这是MS不可避免的必要条件最小化-您可以聪明地使用自己的对象生命周期,使用后备列表而不是大量的新对象/处置等在代码中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM