Jaded
Jaded

Reputation: 1831

Minimizing WCF service client memory usage

I'm implementing a WCF service client which is aimed to test several service methods. That's done by using standard generated proxy class created by Add Web Reference (inherited from 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

// 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. I suspect running them in parallel and increasing iterations count to 100-200 as needed will definitely cause 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.

Upvotes: 0

Views: 707

Answers (1)

Jaded
Jaded

Reputation: 1831

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.

Upvotes: 1

Related Questions