Powershell을 사용하여 많은 메모리를 사용하는 항목 찾기 (64 비트 Windows)


9

Powershell에서 어떤 프로세스 / 가장 많은 메모리를 사용하는지 어떻게 알 수 있습니까?

편집 : 작업 관리자 등이 모든 실제 RAM이 왜 사용되는지 설명하지 못하는 경우 Powershell을 사용하여 모든 실제 메모리를 사용하는 것을 찾는 방법을 알아 내려고합니다. 즉, 캐시 등에 사용되는 메모리를 식별해야합니다.


어떤 종류의 캐시를 생각하십니까?
— squillman

디스크 캐시 ... Windows가 일반적으로 유용한 모든 물리적 메모리를 사용하려고 시도하지 않습니까?
— Andrew J. Brehm

답변:


8

현재 실행중인 프로세스에 대한 정보를 얻고 작업 세트 크기별로 정렬하는 방법은 다음과 같습니다.

Get-Process | Sort-Object -Descending WS

해당 출력을 변수에 할당하면 결과 배열이 제공되고 배열의 첫 번째 멤버 (이 경우 System.Diagnostics.Process 개체)를 작성할 수 있습니다 .

$ProcessList = Get-Process | Sort-Object -Descending WS
Write-Host $ProcessList[0].Handle "::" $Process.ProcessName "::" $Process.WorkingSet

WMI의 Win32_Process 공급자를 사용하여 현재 실행중인 프로세스 목록에서 몇 가지 데이터 항목을 덤프하는 또 다른 빠르고 더러운 스크립트가 있습니다.

$ProcessList = Get-WmiObject Win32_Process -ComputerName mycomputername
foreach ($Process in $ProcessList) {
    write-host $Process.Handle "::" $Process.Name "::" $Process.WorkingSetSize
}

PID (핸들), 프로세스 이름 및 현재 작업 세트 크기가 나열됩니다. WMI Process 클래스 의 다른 속성을 사용하여이를 변경할 수 있습니다 .


내 잘못이야. 나는 충분히 명확하지 않았다. 질문 편집 ...
— Andrew J. Brehm

1

가장 높은 메모리 사용 프로세스의 이름을 찾기위한 하나의 라이너

Get-Process | Sort-Object -Descending WS | select -first 1 | select -ExpandProperty ProcessName

0
$scripthost = Read-Host "Enter the Hostname of the Computer you would like to check Memory Statistics for"
""
""
"===========CPU - Top 10 Utilization List==========="
gwmi -computername $scripthost Win32_PerfFormattedData_PerfProc_Process| sort PercentProcessorTime -desc | select Name,PercentProcessorTime | Select -First 10 | ft -auto
"===========Memory - Top 10 Utilization List==========="
gwmi -computername $scripthost Win32_Process | Sort WorkingSetSize -Descending | Select Name,CommandLine,@{n="Private Memory(mb)";Expression = {[math]::round(($_.WorkingSetSize / 1mb), 2)}} | Select -First 10 | Out-String   
#gwmi -computername $scripthost Win32_Process | Sort WorkingSetSize -Descending | Select Name,CommandLine,@{n="Private Memory(mb)";e={$_.WorkingSetSize/1mb}} | Select -First 10 | Out-String
#$fields = "Name",@{label = "Memory (MB)"; Expression = {[math]::round(($_.ws / 1mb), 2)}; Align = "Right"}; 

"===========Server Memory Information==========="
$fieldPercentage = @{Name = "Memory Percentage in Use (%)"; Expression = { “{0:N2}” -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize)}};     
$fieldfreeram = @{label = "Available Physical Memory (MB)"; Expression = {[math]::round(($_.FreePhysicalMemory / 1kb), 2)}}; 
$fieldtotalram = @{label = "Total Physical Memory (MB)"; Expression = {[math]::round(($_.TotalVisibleMemorySize / 1kb), 2)}}; 
$fieldfreeVram = @{label = "Available Virtual Memory (MB)"; Expression = {[math]::round(($_.FreeVirtualMemory / 1kb), 2)}}; 
$fieldtotalVram = @{label = "Total Virtual Memory (MB)"; Expression = {[math]::round(($_.TotalVirtualMemorySize /1kb), 2)}}; 
$memtotal = Get-WmiObject -Class win32_OperatingSystem -ComputerName $scripthost; 
$memtotal | Format-List $fieldPercentage,$fieldfreeram,$fieldtotalram,$fieldfreeVram,$fieldtotalVram;
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.