开发者

ASP.NET/WCF: Why are logical/physical threads dropping on full GC cycle?

recently I record several hours of .NET Memory counters of a WCF service. The service is hosted in IIS on a Win2k8, 8 core, x64 with 20GB ram.

I can see the GC being pretty healthy, performing a full collection only approx. every 2hrs!

I noticed that in the very same time period, the number of physical and logical threads increases. When the full collection occurs, the number of p开发者_JS百科hysical and logical threads drops back and continues to raise again to the same level.

Why does the GC full collection cycle and the drop in threads correlate? Why is the number of threads continuously increasing?

This is pure ASP.NET/WCF threading model. No custom threads being spawned etc.

Thanks, Alex


It looks like the answer was indeed pretty simple: Threads get created and die as the thread pool is grown and shrinked over time. Normally, those threads have a relatively long life-time which means they end up in generation 2. This is why they naturally only cleaned up on a full GC cycle.

The interesting bit is that a very well memory managed application can end up with loads of dead threads which I was able to observe in WinDbg. This is because a Full GC might only happen after several hours or even days! Some MS blog said that those dead threads are not a really nice thing to have as the corresponding unmanaged C++ thread object seems to be quite resource intensive (cannot find the damn blog anymore unfortunatly....). I am wondering if this is one of the rare cases where an induced Full GC would make sense in a certain time interval.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜