I need to process many bitmaps in a short time and i perform that by using threads. Now, i remember about disposing all of them, i have no memory leaks. Generally my app opens few threads (i control count of them - now i execute only 4 at the same time), and each of one process one big bitmap and does some additionall graphic processing.
Everything works fine until i process let me say - up to 100 bitmaps in a row. My app uses opendialog, so i open 100 first bitmaps then my app is automatically processing them. After it's finished, i open next batch of 100 bitmaps and so on (so between those batches there is a significant pause). This works fine. And the app is all the time opened. I see no memory leaks, after processing of last batch it stays stable, i can process more.
Problem appears when i select more bitmaps in a single batch - more than 300, so my app process all of them without a second of pause. Near the end i'am getting GDI+ Out of Memory error and my app hangs with 1.7 GB memory consumed.
My guess is that system is not able to release memory in so short amount of time (and my app is reserving more). Is it possible? How to deal with this? I don't want to just add a dumb delay in process. I'd like to manage that.
Update: The reason is simple, the App was mistakenly compiled as 32 bit and so had only ~2GB available memory. While it takes time for GC to free memory while app is still reserving more for more bitmaps, app reaches the limit, and hangs.
I compiled the app to 64 bit and it works flawlessly. In addition i will control memory usage, so it isn't working so unattended as now. Thanks for all tips and interesting points to improve!