Process.PagedSystemMemorySize64 屬性

定義

取得配置給關聯處理序的可分頁系統記憶體量 (以位元組為單位)。

C#
public long PagedSystemMemorySize64 { get; }
C#
[System.Runtime.InteropServices.ComVisible(false)]
public long PagedSystemMemorySize64 { get; }

屬性值

配置給關聯處理序的系統記憶體量 (以位元組為單位),可以寫入虛擬記憶體分頁檔案。

屬性

範例

下列程式代碼範例會啟動記事本應用程式的實例。 然後,此範例會擷取並顯示相關聯進程的各種屬性。 此範例會偵測進程何時結束,並顯示其結束代碼和尖峰記憶體統計數據。

C#
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;

            // Start the process.
            using (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($"{myProcess} -");
                        Console.WriteLine("-------------------------------------");

                        Console.WriteLine($"  Physical memory usage     : {myProcess.WorkingSet64}");
                        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($"  Paged system memory size  : {myProcess.PagedSystemMemorySize64}");
                        Console.WriteLine($"  Paged memory size         : {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          : {myProcess.ExitCode}");

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

備註

這個屬性值所傳回的值代表進程所使用的目前可分頁系統記憶體大小,以位元組為單位。 系統記憶體是操作系統所使用的實體記憶體,並分成分頁和非分頁集區。 當可分頁記憶體不在使用中時,可以將它傳輸至磁碟上的虛擬記憶體分頁檔案。 若要取得進程所使用的應用程式記憶體大小,請使用 PagedMemorySize64 屬性。

這個屬性可用來監視具有 32 位處理器或 64 位處理器之電腦上的記憶體使用量。 屬性值相當於進程的 集區分頁位元組 性能計數器。

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

另請參閱