Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the memory usage of a .NET application seem to drop when it is minimized?

For example, launch Paint.NET. Then have a look on its memory usage with Task Manager: on my computer, it uses 36Mb.

Then minimize Paint.NET: now it takes only a few more than 1Mb.

This happens with every .NET Application. What happens when a .NET Application is minimized? Is a GC occurring?

like image 247
Larry Avatar asked Oct 06 '08 19:10

Larry


1 Answers

Task Manager shows you the amount of memory belonging to the application that happens to be paged into real memory at the time. When you minimise an application in Windows, the kernel automatically trims the process working set so it takes less memory. This behaviour is not specific to .NET apps.

If you look instead at the process "Private Bytes" value, this will give you a better indication of the amount of memory used by a process. This value will not change when the process working set is trimmed.

Microsoft offers more information at this knowledgebase article: http://support.microsoft.com/kb/293215

like image 155
Greg Hewgill Avatar answered Oct 16 '22 20:10

Greg Hewgill