Process.WorkingSet64 Property

定義

関連付けられたプロセスに割り当てられた物理メモリの量 (バイト単位) を取得します。 Gets the amount of physical memory, in bytes, allocated for the associated process.

[System.Runtime.InteropServices.ComVisible(false)]
public long WorkingSet64 { get; }
プロパティ値

関連付けられたプロセスに割り当てられた物理メモリの量 (バイト単位)。 The amount of physical memory, in bytes, allocated for the associated process.

例外

プラットフォームが Windows 98 または Windows Millennium Edition (Windows Me) であるため、このプロパティはサポートされていません。 The platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

次のコード例では、メモ帳アプリケーションのインスタンスを開始します。The following code example starts an instance of the Notepad application. 例に、取得し、関連付けられたプロセスのさまざまなプロパティを表示します。The example then retrieves and displays various properties of the associated process. 例では、検出プロセスが終了し、終了コードとピーク メモリ統計情報を表示します。The example detects when the process exits, and displays its exit code and peak memory statistics.

#using <system.dll>

using namespace System;
using namespace System::Diagnostics;
int main()
{
   
   // Define variables to track the peak
   // memory usage of the process.
   _int64 peakPagedMem = 0,peakWorkingSet = 0,peakVirtualMem = 0;
   Process^ myProcess = nullptr;
   try
   {
      
      // Start the process.
      myProcess = Process::Start( "NotePad.exe" );
      
      // Display the process statistics until
      // the user closes the program.
      do
      {
         if (  !myProcess->HasExited )
         {
            
            // Refresh the current process property values.
            myProcess->Refresh();
            Console::WriteLine();
            
            // Display current process statistics.
            Console::WriteLine( "{0} -", myProcess );
            Console::WriteLine( "-------------------------------------" );
            Console::WriteLine( "  physical memory usage: {0}", myProcess->WorkingSet64 );
            Console::WriteLine( "  base priority: {0}", myProcess->BasePriority );
            Console::WriteLine( "  priority class: {0}", myProcess->PriorityClass );
            Console::WriteLine( "  user processor time: {0}", myProcess->UserProcessorTime );
            Console::WriteLine( "  privileged processor time: {0}", myProcess->PrivilegedProcessorTime );
            Console::WriteLine( "  total processor time: {0}", myProcess->TotalProcessorTime );
			Console::WriteLine("  PagedSystemMemorySize64: {0}", myProcess->PagedSystemMemorySize64);
            Console::WriteLine("  PagedMemorySize64: {0}", myProcess->PagedMemorySize64);
            
            // Update the values for the overall peak memory statistics.
            peakPagedMem = myProcess->PeakPagedMemorySize64;
            peakVirtualMem = myProcess->PeakVirtualMemorySize64;
            peakWorkingSet = myProcess->PeakWorkingSet64;
            if ( myProcess->Responding )
            {
               Console::WriteLine( "Status = Running" );
            }
            else
            {
               Console::WriteLine( "Status = Not Responding" );
            }
         }
      }
      while (  !myProcess->WaitForExit( 1000 ) );
      Console::WriteLine();
      Console::WriteLine( "Process exit code: {0}", myProcess->ExitCode );
      
      // Display peak memory statistics for the process.
      Console::WriteLine( "Peak physical memory usage of the process: {0}", peakWorkingSet );
      Console::WriteLine( "Peak paged memory usage of the process: {0}", peakPagedMem );
      Console::WriteLine( "Peak virtual memory usage of the process: {0}", peakVirtualMem );
   }
   finally
   {
      if ( myProcess != nullptr )
      {
         myProcess->Close();
      }
   }

}
using System;
using System.Diagnostics;

namespace ProcessSample
{
    class ProcessMonitorSample
    {
        public static void Main()
        {

            // Define variables to track the peak
            // memory usage of the process.
            long peakPagedMem = 0,
                peakWorkingSet = 0,
                peakVirtualMem = 0;

            Process myProcess = null;

            try
            {
                // Start the process.
                myProcess = Process.Start("NotePad.exe");

                // Display the process statistics until
                // the user closes the program.
                do
                {
                    if (!myProcess.HasExited)
                    {
                        // Refresh the current process property values.
                        myProcess.Refresh();

                        Console.WriteLine();

                        // Display current process statistics.

                        Console.WriteLine("{0} -", myProcess.ToString());
                        Console.WriteLine("-------------------------------------");

                        Console.WriteLine("  physical memory usage: {0}",
                            myProcess.WorkingSet64);
                        Console.WriteLine("  base priority: {0}",
                            myProcess.BasePriority);
                        Console.WriteLine("  priority class: {0}",
                            myProcess.PriorityClass);
                        Console.WriteLine("  user processor time: {0}",
                            myProcess.UserProcessorTime);
                        Console.WriteLine("  privileged processor time: {0}",
                            myProcess.PrivilegedProcessorTime);
                        Console.WriteLine("  total processor time: {0}",
                            myProcess.TotalProcessorTime);
                        Console.WriteLine("  PagedSystemMemorySize64: {0}",
                            myProcess.PagedSystemMemorySize64);
                        Console.WriteLine("  PagedMemorySize64: {0}",
                           myProcess.PagedMemorySize64);

                        // Update the values for the overall peak memory statistics.
                        peakPagedMem = myProcess.PeakPagedMemorySize64;
                        peakVirtualMem = myProcess.PeakVirtualMemorySize64;
                        peakWorkingSet = myProcess.PeakWorkingSet64;

                        if (myProcess.Responding)
                        {
                            Console.WriteLine("Status = Running");
                        }
                        else
                        {
                            Console.WriteLine("Status = Not Responding");
                        }
                    }
                }
                while (!myProcess.WaitForExit(1000));


                Console.WriteLine();
                Console.WriteLine("Process exit code: {0}",
                    myProcess.ExitCode);

                // Display peak memory statistics for the process.
                Console.WriteLine("Peak physical memory usage of the process: {0}",
                    peakWorkingSet);
                Console.WriteLine("Peak paged memory usage of the process: {0}",
                    peakPagedMem);
                Console.WriteLine("Peak virtual memory usage of the process: {0}",
                    peakVirtualMem);

            }
            finally
            {
                if (myProcess != null)
                {
                    myProcess.Close();
                }
            }
        }

    }
}
Imports System
Imports System.Diagnostics

Namespace ProcessSample
    Class ProcessMonitorSample

        Public Shared Sub Main()

            ' Define variables to track the peak
            ' memory usage of the process.
            Dim peakPagedMem As Long = 0
            Dim peakWorkingSet As Long = 0
            Dim peakVirtualMem As Long = 0

            Dim myProcess As Process = Nothing

            Try

                ' Start the process.
                myProcess = Process.Start("NotePad.exe")

                ' Display process statistics until
                ' the user closes the program.
                Do

                    If Not myProcess.HasExited Then

                        ' Refresh the current process property values.
                        myProcess.Refresh()

                        Console.WriteLine()

                        ' Display current process statistics.

                        Console.WriteLine("{0} -", myProcess.ToString())
                        Console.WriteLine("-------------------------------------")

                        Console.WriteLine("  physical memory usage: {0}", _
                             myProcess.WorkingSet64)
                        Console.WriteLine("  base priority: {0}", _
                             myProcess.BasePriority)
                        Console.WriteLine("  priority class: {0}", _
                             myProcess.PriorityClass)
                        Console.WriteLine("  user processor time: {0}", _
                             myProcess.UserProcessorTime)
                        Console.WriteLine("  privileged processor time: {0}", _
                             myProcess.PrivilegedProcessorTime)
                        Console.WriteLine("  total processor time: {0}", _
                             myProcess.TotalProcessorTime)
                        Console.WriteLine("  PagedSystemMemorySize64: {0}", _
                            myProcess.PagedSystemMemorySize64)
                        Console.WriteLine("  PagedMemorySize64: {0}", _
                           myProcess.PagedMemorySize64)

                        ' Update the values for the overall peak memory statistics.
                        peakPagedMem = myProcess.PeakPagedMemorySize64
                        peakVirtualMem = myProcess.PeakVirtualMemorySize64
                        peakWorkingSet = myProcess.PeakWorkingSet64

                        If myProcess.Responding Then
                            Console.WriteLine("Status = Running")
                        Else
                            Console.WriteLine("Status = Not Responding")
                        End If
                    End If
                Loop While Not myProcess.WaitForExit(1000)

                Console.WriteLine()
                Console.WriteLine("Process exit code: {0}", myProcess.ExitCode)

                ' Display peak memory statistics for the process.
                Console.WriteLine("Peak physical memory usage of the process: {0}", _
                    peakWorkingSet)
                Console.WriteLine("Peak paged memory usage of the process: {0}", _
                    peakPagedMem)
                Console.WriteLine("Peak virtual memory usage of the process: {0}", _
                    peakVirtualMem)

            Finally
                If Not myProcess Is Nothing Then
                    myProcess.Close()
                End If
            End Try
        End Sub 'Main
    End Class
End Namespace

注釈

このプロパティによって返される値は、ワーキング セット メモリのバイト単位で、プロセスによって使用されるは、現在のサイズを表します。The value returned by this property represents the current size of working set memory used by the process, in bytes. プロセスのワーキング セットが、物理 RAM メモリ、プロセスに現在表示されているメモリ ページのセット。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 instructions in the process modules and the system libraries.

このプロパティは、32 ビット プロセッサまたは 64 ビット プロセッサを持つコンピュータのメモリ使用量の監視に使用できます。This property can be used to monitor memory usage on computers with 32-bit processors or 64-bit processors. プロパティ値が等しく、ワーキング セットプロセスのパフォーマンス カウンター。The property value is equivalent to the Working Set performance counter for the process.

セキュリティ

LinkDemand
直前の呼び出し元に対する完全な信頼。 for full trust for the immediate caller. このメンバーは、部分的に信頼されているコードから使用することはできません。 This member cannot be used by partially trusted code.

適用対象

こちらもご覧ください