3

Apparently the .NET framework has a bug that prevents working set values above 2GB from accurately being determined. Between 2 and 4GB one can apply some xor-ing calculation to obtain the value, but there's no means of obtaining working set values greater than 4GB (using .Net or WMI)

What method can be used - preferably from a PowerShell script - to obtain an accurate measurement of a process' working set when the working set is greater than 4GB?

(some side details can be found in this StackOverflow question)

Shoeless
  • 275
  • 2
  • 12

2 Answers2

2

This is for monitoring a specific process:

"\Process(<process name>)\Working Set" | get-counter -computer <computer>

The output is in bytes, but you can convert it to GB in the following command:

"\Process(<process name>)\Working Set" | get-counter -computer <computer>
| ForEach {$_.CounterSamples} | ForEach {[math]::round($_.cookedvalue/1GB,2)}

Edit: Reading the SO post, I see you are trying to just get any processes over 4 GB, without passing a specific process to the script. Below is a script that will do this, and here is a link to a Scripting Guy blog article that explains how to use the Get-Counter cmdlet:

"\Process(*)\Working Set" | Get-Counter -computer <computer>
| ForEach {$_.CounterSamples} | ? {$_.cookedvalue -gt 4294967296} | ft -AutoSize
August
  • 3,114
  • 16
  • 17
  • Outstanding. So simple. Thank you for clearing the forest of the trees. Like other performance counters, Passing a * as the process name returns the working set for all processes. Thanks again, August. – Shoeless Jul 11 '12 at 12:28
2

I know it's an old question but still alive, this show real 64bit memory usage in powershell:

get-process $Processname -computername $Computername | ft Name,ID,VirtualMemorySize64,PeakVirtualMemorySize64,WorkingSet64,PeakWorkingSet64

and this show memory usage over gps |where {$_.workingset64 -gt 4000Mb }|ft name,pm,workingset64,id

user235614
  • 21
  • 1