Windows – Powershell Get-Process negative memory value

powershellwindows

I was making some verifications with Powershell Get-Process cmdlet and got some weird values about some processes. I tested on a server with a SQL Server Instance running and consuming 3GB+ RAM as Resource Monitor reported, and when running Get-Process, I got negative values for WorkingSet on the SQL server process, another process is consuming 2GB+ of PrivateMemorySize and got the same negative value on PM.

Below are screenshots of the results.

Resource Monitor
The OS is in portuguese, sorry.

Powershell:

enter image description here
Check sqlservr and the last scvhost…

Luckily my script uses WMI (Win32_Process class) to get the processes informations, and the values there are correct and everything matches..

Is it a bug? Maybe with big values? I'm using Powershell v3.

Best Answer

Is this an x64 Server? If so, it's possible this blogpost explains your issue. Apparently it has to do with the way the get-process reads x64 systems memory:

The reason the poster was seeing negative numbers is fairly simple: the WS property is aliased to WorkingSet, but WorkingSet is a 32-bit value. In the poster’s case, the working set size overflowed the 32-bit value, resulting in a negative number being displayed.

The solution according to the blog is ultimately to enforce formatting of the query result:

$process = “*SQL"*” GPS $process | ft name, workingset64 –auto