Process.WorkingSet Свойство

Определение

Внимание!

This property has been deprecated because the type of the property can't represent all valid results. Please use System.Diagnostics.Process.WorkingSet64 instead. http://go.microsoft.com/fwlink/?linkid=14202

Внимание!

This property has been deprecated because the type of the property can't represent all valid results. Please use System.Diagnostics.Process.WorkingSet64 instead. https://go.microsoft.com/fwlink/?linkid=14202

Внимание!

Use WorkingSet64

Возвращает использование физической памяти связанного процесса (в байтах).Gets the associated process's physical memory usage, in bytes.

public:
 property int WorkingSet { int get(); };
public int WorkingSet { get; }
[System.Obsolete("This property has been deprecated because the type of the property can't represent all valid results. Please use System.Diagnostics.Process.WorkingSet64 instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public int WorkingSet { get; }
[System.Obsolete("This property has been deprecated because the type of the property can't represent all valid results. Please use System.Diagnostics.Process.WorkingSet64 instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public int WorkingSet { get; }
[System.Obsolete("Use WorkingSet64")]
public int WorkingSet { get; }
member this.WorkingSet : int
[<System.Obsolete("This property has been deprecated because the type of the property can't represent all valid results. Please use System.Diagnostics.Process.WorkingSet64 instead.  http://go.microsoft.com/fwlink/?linkid=14202")>]
member this.WorkingSet : int
[<System.Obsolete("This property has been deprecated because the type of the property can't represent all valid results. Please use System.Diagnostics.Process.WorkingSet64 instead.  https://go.microsoft.com/fwlink/?linkid=14202")>]
member this.WorkingSet : int
[<System.Obsolete("Use WorkingSet64")>]
member this.WorkingSet : int
Public ReadOnly Property WorkingSet As Integer

Значение свойства

Int32

Полное количество физической памяти в байтах, которое использует связанный процесс.The total amount of physical memory the associated process is using, in bytes.

Атрибуты

Примеры

В следующем примере запускается экземпляр блокнота.The following example starts an instance of Notepad. Затем в примере извлекаются и отображаются различные свойства связанного процесса.The example then retrieves and displays various properties of the associated process. В примере обнаруживается, когда процесс завершается, и отображается код выхода процесса.The example detects when the process exits, and displays the process' exit code.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main()
{
   try
   {
      Process^ myProcess;
      myProcess = Process::Start( "NotePad.exe" );
      while (  !myProcess->HasExited )
      {
         Console::WriteLine();
         
         // Get physical memory usage of the associated process.
         Console::WriteLine( "Process's physical memory usage: {0}", myProcess->WorkingSet.ToString() );
         
         // Get base priority of the associated process.
         Console::WriteLine( "Base priority of the associated process: {0}", myProcess->BasePriority.ToString() );
         
         // Get priority class of the associated process.
         Console::WriteLine(  "Priority class of the associated process: {0}", myProcess->PriorityClass );
         
         // Get user processor time for this process.
         Console::WriteLine( "User Processor Time: {0}", myProcess->UserProcessorTime.ToString() );
         
         // Get privileged processor time for this process.
         Console::WriteLine( "Privileged Processor Time: {0}", myProcess->PrivilegedProcessorTime.ToString() );
         
         // Get total processor time for this process.
         Console::WriteLine( "Total Processor Time: {0}", myProcess->TotalProcessorTime.ToString() );
         
         // Invoke overloaded ToString function.
         Console::WriteLine( "Process's Name: {0}", myProcess->ToString() );
         Console::WriteLine( "-------------------------------------" );
         if ( myProcess->Responding )
         {
            Console::WriteLine( "Status:  Responding to user interface" );
            myProcess->Refresh();
         }
         else
         {
            Console::WriteLine( "Status:  Not Responding" );
         }
         Thread::Sleep( 1000 );
      }
      Console::WriteLine();
      Console::WriteLine(  "Process exit code: {0}", myProcess->ExitCode.ToString() );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "The following exception was raised:  {0}", e->Message );
   }

}

using System;
using System.Diagnostics;
using System.Threading;

namespace ProcessSample
{
    class MyProcessClass
    {
        public static void Main()
        {
            try
            {
                using (Process myProcess = Process.Start("NotePad.exe"))
                {
                    while (!myProcess.HasExited)
                    {
                        Console.WriteLine();

                        Console.WriteLine($"Physical memory usage     : {myProcess.WorkingSet}");
                        Console.WriteLine($"Base priority             : {myProcess.BasePriority}");
                        Console.WriteLine($"Priority class            : {myProcess.PriorityClass}");
                        Console.WriteLine($"User processor time       : {myProcess.UserProcessorTime}");
                        Console.WriteLine($"Privileged processor time : {myProcess.PrivilegedProcessorTime}");
                        Console.WriteLine($"Total processor time      : {myProcess.TotalProcessorTime}");
                        Console.WriteLine($"Process's Name            : {myProcess}");
                        Console.WriteLine("-------------------------------------");

                        if (myProcess.Responding)
                        {
                            Console.WriteLine("Status:  Responding to user interface");
                            myProcess.Refresh();
                        }
                        else
                        {
                            Console.WriteLine("Status:  Not Responding");
                        }

                        Thread.Sleep(1000);
                    }

                    Console.WriteLine();
                    Console.WriteLine($"Process exit code: {myProcess.ExitCode}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"The following exception was raised: {e.Message}");
            }
        }
    }
}
Imports System.Diagnostics
Imports System.Threading

Namespace Process_Sample
    Class MyProcessClass

        Public Shared Sub Main()
            Try

                Using myProcess = Process.Start("NotePad.exe")

                    While Not myProcess.HasExited

                        Console.WriteLine()

                        Console.WriteLine($"Process's physical memory usage          : {myProcess.WorkingSet}")
                        Console.WriteLine($"Base priority of the associated process  : {myProcess.BasePriority}")
                        Console.WriteLine($"Priority class of the associated process : {myProcess.PriorityClass}")
                        Console.WriteLine($"User processor time                      : {myProcess.UserProcessorTime}")
                        Console.WriteLine($"Privileged processor time                : {myProcess.PrivilegedProcessorTime}")
                        Console.WriteLine($"Total processor time                     : {myProcess.TotalProcessorTime}")
                        Console.WriteLine($"Process's name                           : {myProcess}")
                        Console.WriteLine("-------------------------------------")

                        If myProcess.Responding Then
                            Console.WriteLine("Status:  Responding to user interface")
                            myProcess.Refresh()
                        Else
                            Console.WriteLine("Status:  Not Responding")
                        End If
                        Thread.Sleep(1000)
                    End While

                    Console.WriteLine()
                    Console.WriteLine($"Process exit code: {myProcess.ExitCode}")
                End Using

            Catch e As Exception
                Console.WriteLine($"The following exception was raised: {e.Message}")
            End Try
        End Sub
    End Class
End Namespace 'Process_Sample

Комментарии

Значение, возвращаемое этим свойством, представляет самый последний обновленный размер памяти рабочего набора, используемый процессом, в байтах.The value returned by this property represents the most recently refreshed size of working set memory used by the process, in bytes. Чтобы получить наиболее актуальный размер, сначала необходимо вызвать Refresh() метод.To get the most up to date size, you need to call Refresh() method first.

Рабочий набор процесса — это набор страниц памяти, которые в настоящее время видны процессу в физической ОПЕРАТИВной памяти.The working set of a process is the set of memory pages currently visible to the process in physical RAM memory. Эти страницы являются резидентными и доступны для использования приложением без активации ошибки страницы.These pages are resident and available for an application to use without triggering a page fault.

Рабочий набор включает как общие, так и частные данные.The working set includes both shared and private data. Общие данные включают страницы, содержащие все инструкции, выполняемые процессом, включая модули процессов и системные библиотеки.The shared data includes the pages that contain all the instructions that the process executes, including the process modules and the system libraries.

Применяется к

См. также раздел