OutOfMemoryException异常,堆栈大小是巨大的,大量的线程 [英] OutOfMemoryException, stack size is huge, large number of threads

查看:253
本文介绍了OutOfMemoryException异常,堆栈大小是巨大的,大量的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我分析我的.NET Windows服务。 我试图发现OutOfMemoryException异常,发现我的堆栈大小 是巨大的,不断增长,因为线程的数量不断增加。

每个线程都有 1024 KB 在Windows x64的机器。因此,当我的应用程序具有的 754 线程的堆栈大小将是 772 MB 。我的问题是,我不知道这些线索从何而来。最初,我的应用程序有一个非常有限的线程数,他们不断增长的使用时间。

我有两个怀疑 - 无论这些线程是由WCF或数据库连接创建。 我的应用程序同时使用WCF和数据集。此外,我想我的个人资料在蚂蚁的应用程序不跟踪我可以看到大量的 System.ServiceModel.Channels.ClientReliableDuplexSessionChannel 而且这个数字还在不断增加与时间。我可以看到成千上万创建这些对象。所以我想知道的是谁在创建线程(工具来发现,廓线仪),如果它是WCF是谁创建这些线程。

更新

我已经停止在调试我的应用程序来看看线程。所有我能看到大量的Win32线程有这样的调用堆栈

  ntdll.dll中!7c82860c()
[相框下面可能是不正确的和/或缺失,没有加载ntdll.dll中的符号]
ntdll.dll中!7c827d99()
KERNEL32.DLL!77e4e02f()
的Mscorwks.dll!79e7c7a8()
的Mscorwks.dll!79f943fe()
的Mscorwks.dll!79f94237()
mscorlib.ni.dll!792f5577()
mscorlib.ni.dll!792e01c5()
 

解决方案

您可以看看使用调试器程序 - 那么,你可以看到所有这些线程都在做(其中大部分可能有一个非常类似的调用堆栈)。

I was profiling my .net windows service. I was trying to discover OutOfMemoryException and discovered that my stack size is huge and is growing because the the number of threads keeps growing.

Each thread gets 1024 KB on Windows x64 machine. Thus when my app has 754 threads the stack size would be 772 MB. The problem for me is that i don't know where these thread come from. Initially my app has a very limited number of threads and they keep growing with time.

I have two suspicions - either these threads are created by WCF or by database connection. My application uses both WCF and datasets. Also I tried to profile my app in Ants do Trace i can see large number of System.ServiceModel.Channels.ClientReliableDuplexSessionChannel and this number is increasing with time. I can see thousands of these objects created. So what I want to know is who is creating threads (tools to discover, profilers) and if it is WCF who is creating these threads.

UPDATE

I have stopped in debugger my app to look at the threads. All I can see a large number of Win32 threads with call stack like that

ntdll.dll!7c82860c()    
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
ntdll.dll!7c827d99()    
kernel32.dll!77e4e02f()     
mscorwks.dll!79e7c7a8()     
mscorwks.dll!79f943fe()     
mscorwks.dll!79f94237()     
mscorlib.ni.dll!792f5577()  
mscorlib.ni.dll!792e01c5()  

解决方案

You could look at the program using a debugger - then you can see what all those threads are doing (most of them probably have a very similar call stack).

这篇关于OutOfMemoryException异常,堆栈大小是巨大的,大量的线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆