.NET Garbage Collection causing unresponsive behavior

sevzas used Ask the Experts™
I'm working on a desktop where respnsiveness is extremely important.  When the app is running, it is receiving and sending out streams of data.  It is also updating the display for the user.

We also have a background timer (System.Threading.Timer) that runs every second and logs some statistics to a file using log4net.

The garbage collection is configured to be the default gcConcurrent=true, gcServer=false.  The resulting LatencyMode is "Interactive".  The app is running on Windows Server 2008 on a 4 core machine with 8 Gb RAM.  There is plenty of free memory.

Once in a while the app becomes unresponsive for up to 10 seconds.  The GUI freezes up, but the most interesting thing is that the Timer stops firing!  When the "freeze" is over, the missed timer events are processed in rapid succession.  The Timer callback is very lightweight and does very minimal logging - 1 line.

The question is - what could cause the freezing?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You might use some of the perfmon garbage collection counters to verify that the freeze coincides with a garbage collection.  If it does, you might start by reading:

I've determined that this behavior is caused by another portion of the system that is putting too many requests into the ThreadPool too fast.  Basically overwhelms the Threadpool.  Timer callback invocations are placed in the Threadpool, so they all compete for priority.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial