Process.PrivateMemorySize64 속성

정의

연결된 프로세스에 할당된 전용 메모리의 양(바이트)을 가져옵니다.

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

속성 값

연결된 프로세스에 할당되어 다른 프로세스와는 공유할 수 없는 메모리의 양(바이트)입니다.

특성

예제

다음 코드 예제에서는 메모장 애플리케이션의 인스턴스를 시작 합니다. 그런 다음, 이 예제에서는 연결된 프로세스의 다양한 속성을 검색하고 표시합니다. 이 예제에서는 프로세스가 종료되는 시기를 감지하고 종료 코드 및 최대 메모리 통계를 표시합니다.

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

설명

이 속성에서 반환되는 값은 다른 프로세스와 공유할 수 없는 프로세스에서 가장 최근에 새로 고친 메모리 크기(바이트)를 나타냅니다. 최신 크기를 최대한 활용하려면 먼저 메서드를 호출 Refresh() 해야 합니다.

이 속성은 32비트 프로세서 또는 64비트 프로세서가 있는 컴퓨터에서 메모리 사용량을 모니터링하는 데 사용할 수 있습니다. 속성 값은 프로세스의 Private Bytes 성능 카운터와 동일합니다.

적용 대상

제품 버전
.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