英語で読む

次の方法で共有


Process.WorkingSet プロパティ

定義

注意事項

This property has been deprecated. Please use System.Diagnostics.Process.WorkingSet64 instead. https://go.microsoft.com/fwlink/?linkid=14202

注意事項

Process.WorkingSet has been deprecated because the type of the property can't represent all valid results. Use System.Diagnostics.Process.WorkingSet64 instead.

注意事項

This property has been deprecated. Please use System.Diagnostics.Process.WorkingSet64 instead. http://go.microsoft.com/fwlink/?linkid=14202

関連付けられたプロセスの物理メモリ使用量 (バイト単位) を取得します。

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

プロパティ値

関連付けられたプロセスが使用している物理メモリの合計容量 (バイト単位)。

属性

次の例では、メモ帳のインスタンスを開始します。 次に、この例では、関連付けられているプロセスのさまざまなプロパティを取得して表示します。 この例では、プロセスが終了したときにを検出し、プロセスの終了コードを表示します。

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}");
            }
        }
    }
}

注釈

このプロパティによって返される値は、プロセスによって使用されるワーキング セット メモリの最後に更新されたサイズをバイト単位で表します。 最新のサイズを取得するには、まず メソッドを呼び出す Refresh() 必要があります。

プロセスのワーキング セットとは、プロセスが物理 RAM メモリ内で現在参照できるメモリ ページのセットです。 これらのページは常駐しており、ページ フォールトをトリガーすることなくアプリケーションから使用できます。

ワーキング セットには、共有データとプライベート データの両方が含まれます。 共有データには、プロセス モジュールやシステム ライブラリなど、プロセスが実行するすべての命令を含むページが含まれます。

適用対象

こちらもご覧ください