.png)
Powershell에서 가장 많은 메모리를 사용하는 프로세스/무엇이 무엇인지 어떻게 알 수 있나요?
편집: 작업 관리자 등이 모든 물리적 RAM을 모두 사용한 이유를 설명하지 못하는 경우 Powershell을 사용하여 모든 물리적 메모리를 사용하는 것이 무엇인지 알아내는 방법을 알아내려고 노력 중입니다. 즉, 캐시 등에서 사용되는 메모리를 식별해야 합니다.
답변1
현재 실행 중인 프로세스에 대한 정보를 얻고 작업 세트 크기별로 정렬하는 방법은 다음과 같습니다.
Get-Process | Sort-Object -Descending WS
해당 출력을 변수에 할당하면 결과 배열이 제공됩니다. 그런 다음 배열의 첫 번째 구성원을 작성할 수 있습니다(이 경우에는시스템.진단.프로세스물체).
$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 프로세스 클래스.
답변2
가장 높은 메모리 사용량 프로세스의 이름을 찾는 하나의 라이너
Get-Process | Sort-Object -Descending WS | select -first 1 | select -ExpandProperty ProcessName
답변3
$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;