Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I find out (in Powershell) what process/whatever uses the most memory?

Edit: I am trying to figure out how to use Powershell to find out what's using all the physical memory in case Task Manager etc. fail to explain why all the physical RAM is used up. I.e. I need to identify memory used by caches etc.

share|improve this question
    
What kind of cache are you thinking of? –  squillman Jan 18 '10 at 17:32
    
Disk cache... Wouldn't Windows usually try to use all available physical memory for something useful? –  Andrew J. Brehm Jan 18 '10 at 19:36
add comment

1 Answer

up vote 3 down vote accepted

Here's a way to get info on currently running processes and sort by Working Set size

Get-Process | Sort-Object -Descending WS

Assign that output to a variable and it'll give you an array of the results, then you can just write out the first member of the array (which in this case will be a System.Diagnostics.Process object).

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

Here's another quick and dirty script to dump a few items of data from the list of currently running processes using WMI's Win32_Process provider:

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

That'll list the PID (handle), process name and the current working set size. You can change that up using different properties of the WMI Process class.

share|improve this answer
    
My bad. I wasn't clear enough. Question edited... –  Andrew J. Brehm Jan 18 '10 at 17:24
    
It's not getting better than this. Thanks. –  Andrew J. Brehm Feb 15 '10 at 15:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.