4

Here's the scenario, winforms application, monitoring via Task Manager Processes Tab.

On initial launch spins up to ~61,000K (initial data grid and data loads) If I minimize the application, not touching or doing anything the Mem usage drops to 1,380K. When I restore the application is spins back up to only 5.8K

So my question is, does the minimize send some internal message to clean up resources since the application in question is not in focus?

The first app I noticed this in happens to be VB.NET, but I've observed the same behavior in my main C# winform applications.

curtisk
  • 19,950
  • 4
  • 55
  • 71
  • Maybe a duplicate of: http://stackoverflow.com/questions/4863016/is-it-true-that-in-net-garbage-collector-gets-called-when-you-minimize-the-progr – Simon Mourier Feb 08 '11 at 17:10
  • Yes, the other question covers it nicely....sorry I didn't see it when reviewing the suggested dupes while typing this up...can't delete since there's an answer, voted to close – curtisk Feb 08 '11 at 17:18
  • You'll notice this in *all* of your applications, not just those targeting the .NET Framework. Hans's answer is good here; the answers to the duplicate question have a bunch of additional information. – Cody Gray - on strike Feb 09 '11 at 04:02
  • @Cody Gray: Yes I have since noticed that, it just stood out since we were looking further under the covers on this particular app, we've since moved to using perfmon and SOS for analysis, thanks – curtisk Feb 09 '11 at 14:49

1 Answers1

7

You are looking at the wrong memory statistic. That's "working set", the amount of virtual memory that's mapped to physical memory. RAM. Windows aggressively trims the working set when it detects the main window getting minimized. It assumes the user won't be using the program for a while so it unmaps pages from RAM to make room for other processes. When you give it the focus back, Windows only maps pages back to RAM that are actually needed. Which isn't many of them when the app is otherwise idle.

Garbage collection is a virtual memory operation.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536