I am getting Out of Memory exception
in my C# application while processing images. I am testing it on my computer where I have 8GB of ram, way more than used by the app.
I've checked the GC.TotalMemory(false)
. Before the processing runs it says (converted to MB) 2MB, after without waiting for the garbage collection it says 4MB. While processing it reaches 81 MB at the peak.
I first thought that it something to do with the binding restrictions, because it works inside a WCF service, but didn't find any parameter that can lead to that exception.
I think that my application should have no problem running with 81MP memory used at the peak, and even more. What I am doing wrong? -- Thanks.
The loop that runs the processing:
Parallel.For(0, count, i =>
{
Task<int>.Factory.FromAsync(proxy.BeginSaveImage(sp, new AsyncCallback(CompleteSave), state), proxy.EndSaveImage).ContinueWith(result => {});
});
Runs in parallel and calls the image processing method asynchronously.