Memory Report from Windows Task Manager

This section provides a tutorial example on how to use Windows Task Manager to verify memory usage numbers reported by the System.Diagnostics.Process class.

To verify memory usage numbers reported by the System.Diagnostics.Process class, I wrote another tutorial example program which calls System.Threading.Thread.Sleep() to keep the program running. Then "Windows Task Manager" can be used to see memory usage numbers reported by the Windows system.

1. Compile the tutorial example program below with .NET 4 C# compiler:

// LongSleep.cs
// Copyright (c) 2015,, All Rights Reserved.

using System;
public class LongSleep {
   public static void Main() {
      System.Diagnostics.Process proc 
         = System.Diagnostics.Process.GetCurrentProcess();
      Console.WriteLine("Current process: {0}", proc.ToString());

      Console.WriteLine("Private Memory: {0}", 
      Console.WriteLine("Virtual Memory: {0}", 
      Console.WriteLine("Working Set: {0}", 
      Console.WriteLine("Paged Memory: {0}", 
      Console.WriteLine("Paged System Memory: {0}", 
      Console.WriteLine("Non-paged System Memory: {0}", 

2. Run the tutorial example program, LongSleep.exe.

Current process: System.Diagnostics.Process (LongSleep)
Private Memory: 8740864
Virtual Memory: 89157632
Working Set: 5591040
Paged Memory: 8740864
Paged System Memory: 100228
Non-paged System Memory: 3988

3. Run "Windows Task Manager" and click "View" > "Select Columns..." menu. The "Select Columns" dialog box shows up.

4. Check "Memory Usage", "Virtual Memory Size", "Paged Pool" and "Non-paged Pool" checkboxes and click OK.

5. Check "Processes" tab and look at the "LongSleep.exe" row:
Windows Task Manager

Memory usage numbers reported for LongSleep.exe are:

Image Name: LongSleep.exe
Mem Usage: 5,904 K
VM Size: 8,676 K
Paged Pool: 98 K
NP Pool: 3 K

6. Compare the program output and the "Windows Task Manager" report, we can map "Windows Task Manager" values to System.Diagnostics.Process properties:

    Windows Task Manager     System.Diagnostics.Process

            Memory Usage  =  Working Set
VM (Virtual Memory) Size  =  Private Memory
              Paged Pool  =  Paged System Memory
     NP (Non-paged) Pool  =  Non-paged System Memory

Last update: 2015.

Table of Contents

 About This Book

 Introduction of C# (C Sharp)

 Data Type and Variables

 Logical Expressions and Conditional Statements

 Arrays and Loop Statements

 Data Type Features

 Floating-Point Data Types

 Passing Parameters to Methods

 Execution Environment Class

 Visual C# 2010 Express Edition

 Class Features

 C# Compiler and Intermediate Language

 Compiling C# Source Code Files

 MSBuild - Microsoft Build Engine

Memory Usages of Processes

 Using "Process" Class to Show Memory Usages

 Private/Virtual Memory and Working Set

 Footprints of Private and Shared Memories

 Virtual Memory Upper Limit

Memory Report from Windows Task Manager

 Memory Report from Performance Console

 Multithreading in C#

 Async Feature from C# 5

 System.IO.FileInfo Class

 System.Diagnostics.FileVersionInfo Class

 WPF - Windows Presentation Foundation

 Partial Classes and Partial Methods

 Outdated Tutorials


 PDF Printing Version