C# HttpWebRequest.GetResponse在内存可用时抛出OfMemory

C# HttpWebRequest.GetResponse在内存可用时抛出OfMemory,c#,.net,windows,winapi,memory,C#,.net,Windows,Winapi,Memory,出现问题的应用程序是一个windows服务,在约3000台机器上运行,对绝大多数机器运行良好。但是,在大约20台机器上,它将定期开始出现故障,并出现未处理的OutOfMemory异常。如果我让客户重新启动,那么错误会持续一周(直到内存使用率再次升高)。应用程序本身没有占用太多内存,对GetResponse()的调用失败的可能性很小 下面是确切的错误消息: Insufficient memory to continue the execution of the program. 和堆栈跟踪: a

出现问题的应用程序是一个windows服务,在约3000台机器上运行,对绝大多数机器运行良好。但是,在大约20台机器上,它将定期开始出现故障,并出现未处理的OutOfMemory异常。如果我让客户重新启动,那么错误会持续一周(直到内存使用率再次升高)。应用程序本身没有占用太多内存,对GetResponse()的调用失败的可能性很小

下面是确切的错误消息:

Insufficient memory to continue the execution of the program.
和堆栈跟踪:

at System.Net.WinHttpWebProxyFinder.GetLastWin32Error()
at System.Net.WinHttpWebProxyFinder.GetProxies(Uri destination, Uri scriptLocation, String& proxyListString)
at System.Net.WinHttpWebProxyFinder.GetProxies(Uri destination, IList`1& proxyList)
at System.Net.HybridWebProxyFinder.GetProxies(Uri destination, IList`1& proxyList)
at System.Net.AutoWebProxyScriptEngine.GetProxies(Uri destination, IList`1& proxyList, Int32& syncStatus)
at System.Net.WebProxy.GetProxiesAuto(Uri destination, Int32& syncStatus)
at System.Net.ProxyScriptChain.GetNextProxy(Uri& proxy)
at System.Net.ProxyChain.ProxyEnumerator.MoveNext()
at System.Net.ServicePointManager.FindServicePoint( Uri address, IWebProxy proxy, ProxyChain& chain, HttpAbortDelegate& abortDelegate, Int32& abortState)
at System.Net.HttpWebRequest.FindServicePoint(Boolean forceFind)
at System.Net.HttpWebRequest.GetResponse()
at ROS.RT.Client.Proxy.GetReponse(WebRequest req, Int32 tries)
at ROS.RT.Client.Proxy.GetCommands()
下面是调用GetResponse()的代码:

我在上次失败时运行了systeminfo,它显示了可用内存

Total Physical Memory:     3,548 MB
Available Physical Memory: 1,144 MB
Virtual Memory: Max Size:  7,397 MB
Virtual Memory: Available: 2,227 MB
Virtual Memory: In Use:    5,170 MB
据我所知,应用程序本身使用了大约6MB的内存。它似乎没有走那么远,但对web请求的典型响应是~1KB

在这一点上,我已经告诉客户,除了我的应用程序之外,他们机器上的某些东西存在内存泄漏,导致我的应用程序失败。然而,我并不完全理解这里发生了什么


当内存可用时,什么会导致WinHttpWebProxyFinder.GetProxies抛出内存?

如果不查看一些代码,很难仅根据您的异常做出任何假设。但我会努力的。如果您的应用程序是x86-例如,您的应用程序可能会遇到2 GB的内存限制。20台计算机是否会因相同的堆栈跟踪而崩溃,例如
System.Net.WinHttpWebProxyFinder.GetProxies()
是在
GetLastWin32Error()
之前调用的最后一个东西?@Andy我已经用代码更新了帖子。我最初没有包括它,因为它太琐碎了。@JasonEvans-是的,所有的堆栈跟踪都失败了。潜在的错误是Windows错误代码,错误是内存不足。这并不一定意味着程序内存不足,内核的内存池也可能耗尽。不是由错误的驱动程序或另一个泄露句柄的程序引起的。这是一项IT人员需要解决的工作,除非他们愿意为您购买机票。你可能应该拒绝:)
Total Physical Memory:     3,548 MB
Available Physical Memory: 1,144 MB
Virtual Memory: Max Size:  7,397 MB
Virtual Memory: Available: 2,227 MB
Virtual Memory: In Use:    5,170 MB