简体   繁体   English

最小化WCF服务客户端内存使用量

[英]Minimizing WCF service client memory usage

I'm implementing a WCF service client which is aimed to test several service methods. 我正在实现一个WCF服务客户端,该客户端旨在测试几种服务方法。 That's done by using standard generated proxy class created by Add Web Reference (inherited from System.Web.Services.Protocols.SoapHttpClientProtocol ). 这是通过使用由Add Web Reference(从System.Web.Services.Protocols.SoapHttpClientProtocol继承)创建的标准生成的代理类完成的。 What I need to do is execute certain type of requests many times simultaneously to see how it will affect server performance (something like capacity testing for server infrastructure). 我需要做的是同时多次执行某种类型的请求,以查看它如何影响服务器性能(类似于对服务器基础结构的容量测试)。 Here's the problem - each of responses to these requests is pretty large (~10-100 mb) and I see that only few calls like 这是问题所在-对这些请求的每个响应都很大(〜10-100 mb),我看到只有几个电话像

// parametersList.Count = 5
foreach(var param in parametersList)
{
    var serviceResponse = serviceWebReferenceProxy.ExecuteMethod(param);
    // serviceResponse is not saved anywhere else,
    // expected to be GC'd after iteration
}

causes Private bytes of process to jump to ~500 mb of memory and Working Set to 200-300 mb. 导致进程的专用字节跳到〜500 mb的内存,而工作集跳到200-300 mb。 I suspect running them in parallel and increasing iterations count to 100-200 as needed will definitely cause StackOverflow/OutOfMemoryException. 我怀疑并行运行它们并根据需要将迭代计数增加到100-200肯定会导致StackOverflow / OutOfMemoryException。 How this can be done then? 那怎么办呢? I'm expecting removal of assigning service method response to variable will help, but that's a problem because I need to see each response's size. 我期望删除将服务方法响应分配给变量会有所帮助,但这是一个问题,因为我需要查看每个响应的大小。 I'm looking for some sort of instant and guaranteed memory cleanup after each iteration. 我正在每次迭代后寻找某种即时且有保证的内存清理。

Refactored logic to reuse existing objects as much as possible, which gave an ability to run more clients. 重构逻辑以尽可能多地重用现有对象,这使它能够运行更多客户端。 After certain period of time garbage collecting becomes very slow but performance is acceptable. 经过一定时间后,垃圾收集变得非常缓慢,但性能可以接受。

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

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