My Photo
Name:
Location: United States

Monday, June 19, 2006

Strange Memory Behavior when Minimizing Applications

robgruen's WebLog : Strange Memory Behavior when Minimizing Applications on Windows XP

What you are seeing is expected behavior. Here's a recap of scenario two: Your application loads and its memory footprint grows so the OS allocates larger chunks of memory to it because it has memory available. If you attach perfmon to your application you'll see the working set and the private bytes increase however most likely the growth between the two counters will not be linear (working set will grow faster than private bytes). Then the app gets minimized....



At this point the os flushes all of the unused memory pages (those not doing any work) of your application to virtual memory (the paging file) and most of the working set is released back to the OS for use in other applications because your app isn't doing anything and no longer needs it. Hence the decrease to .82MB, most likely this is the memory for the message pump for the application and possibly the main window and it's resources. Then the application is reactivated...



The cpu starts running instructions on your process and pages are fetched from the paging file as necessary. Since the OS has already loaded most of your application and recognizes that your application is not allocating more memory, it (the os) only allocates very small/if any amounts of working set to your app. That is why it is now at 2.5MB instead of 16MB.





The best way for you to view this is to use perfmon and watch working set, virtual memory, and private bytes while you do scenario 2 from your mail. You'll see the behavior I describe above. In a citrix enviroment you'll see tha the OS is more sparing with the working set as more and more users consume more resources.

0 Comments:

Post a Comment

<< Home