Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
System
Environment Class
 WorkingSet Property
Collapse All/Expand All Collapse All
.NET Framework Class Library
Environment..::.WorkingSet Property

Updated: March 2011

Gets the amount of physical memory mapped to the process context.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic
Public Shared ReadOnly Property WorkingSet As Long
C#
public static long WorkingSet { get; }
Visual C++
public:
static property long long WorkingSet {
    long long get ();
}
F#
static member WorkingSet : int64

Property Value

Type: System..::.Int64
A 64-bit signed integer containing the number of bytes of physical memory mapped to the process context.

The WorkingSet property returns a value that is retrieved through an unmanaged helper library. For more information, see the GetProcessMemoryInfo function and the PROCESS_MEMORY_COUNTERS structure.

Windows 98, Windows Millennium Edition Platform Note: This property always returns zero.

The following example displays the size of the working set of the computer that runs the code example.

Visual Basic
' Sample for the Environment.WorkingSet property
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine("WorkingSet: {0}", Environment.WorkingSet)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'WorkingSet: 5038080
'
C#
// Sample for the Environment.WorkingSet property
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine("WorkingSet: {0}", Environment.WorkingSet);
    }
}
/*
This example produces the following results:

WorkingSet: 5038080
*/
Visual C++
// Sample for the Environment::WorkingSet property
using namespace System;
int main()
{
   Console::WriteLine( "WorkingSet: {0}", Environment::WorkingSet );
}

/*
This example produces the following results:

WorkingSet: 5038080
*/

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Date

History

Reason

March 2011

Added information about the unmanaged library.

Customer feedback.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
WorkingSet reported incorrectly      lockedscope   |   Edit   |   Show History
Environment.WorkingSet returns the working set incorrectly on a windows 2003 server sp2 with 3GBs of Ram. It reports working set as 2047468061 bytes(1952MBs). Process.WorkingSet value is 75563008 bytes(72MBs). On a Vista machine with 3GBs of Ram, Environment.WorkingSet is 37 MBs.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker