title: C# OutOfMemoryException - How to track down the culprit
body: <p>I have a C#/WPF application that is meant to run on a small panel PC with 512 MB of memory. If it is left to run, an OutOfMemoryException is eventually thrown. This can take 12+ hours up to 2 days to happen.</p>
  
  <p>Using both ProcessExplorer and .NET Memory Profiler, I see no evidence that the memory used by my application is growing over time. There is just a typical pattern of a little growth followed by garbage collection. </p>
  
  <p>I've added code to print out all running processes and their memory information when the exception is thrown. I'm currently just waiting around for it to happen again. I should mention that PCs are flash based and paging is disabled. The 512 is a hard limit.</p>
  
  <p>It has happened on two separate PCs. The exception information was the same in both cases:</p>
  
  <pre><code>Top Level Exception - System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
      at System.Windows.Media.Composition.DUCE+Channel.SendCommand(Byte* pCommandData, Int32 cSize)
      at System.Windows.Media.MediaContext.EnterInterlockedPresentation()
      at System.Windows.Media.MediaContext.ScheduleNextRenderOp(TimeSpan minimumDelay)
      at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
      at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
      at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
      at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
  </code></pre>
  
  <p>Any insight is appreciated!</p>