Is there anything special I have to do to gracefully close the stream when it makes a WCF call while it is being processed?
It seems that I am getting a memory leak on my server and I tracked it to make a WCF call from my worker threads. I create threads in a simple way, for example ...
var schedule = new Schedule(); var scheduleThread = new Thread(New ParameterizedThreadStart(schedule.Run)); scheduleThread.SetApartmentState(ApartmentState.STA); scheduleThread.Priority = ThreadPriority.Lowest; scheduleThread.Start(null);
... and code to execute my test code that has a problem ...
public void Run(object param) { var wcf = new TestServer.TestServerClient(...); wcf.Open(); wcf.Ping(); wcf.Close(); }
... after starting 2000 times, I see, using the memory profiler, that there are 2000 instances of the following classes ...
DispatcherOperationCallback IntPtr HwndSubclass NativeMethods.WndProc
So, is there any kind of cleanup I have to do that involves using WCF from the stream? The call to GC.Collect () is not affected.
source share