Hello,
I'd like to understand a problem I'm currently facing.
I created a C# application using Winforms. I have a long running operation (several minutes).
When I launched this operation to test it directly in one of my control in the GUI layer (say, "onButtonTestClicked()"), the windows was frozen as I expected, and the application grew and grew up to 2 giga in memory(!), causing this OutOfMemory exception.
However, when I launched my long operation in a new thread from onButtonTestClicked(), it used only up to 200 mega.
I suspect this issue is linked to Windows message pumping: when the app is frozen, it can't pump messages as it should. But what is the link with all that memory space taken?
Could you explain why? I'm quite curious about it.
Thanks !
What I have tried:
Well, I didn't find much on the internet. Here is some piece of documentation:
About Messages and Message Queues (Windows)[
^]
When debugging, I have this error message:
The CLR has been unable to transition from COM context 0x1a0b88 to COM context 0x1a0cf8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.