Free memory
Total and available RAM
Section titled “Total and available RAM”$os = Get-CimInstance Win32_OperatingSystem[pscustomobject]@{ TotalGB = [math]::Round($os.TotalVisibleMemorySize / 1MB, 1) AvailableGB = [math]::Round($os.FreePhysicalMemory / 1MB, 1) UsedPercent = [math]::Round((1 - $os.FreePhysicalMemory / $os.TotalVisibleMemorySize) * 100)}TotalVisibleMemorySize and FreePhysicalMemory come in kilobytes, so dividing by 1MB (1,048,576) gives gigabytes.
Which processes are using it
Section titled “Which processes are using it”Get-Process | Sort-Object WorkingSet64 -Descending | Select-Object -First 10 Name, Id, @{ n = 'MemoryMB'; e = { [math]::Round($_.WorkingSet64 / 1MB) } }The working set is the physical RAM the process is using right now.
Total memory per program (adds up all the processes with the same name, such as every Chrome tab):
Get-Process | Group-Object Name | ForEach-Object { [pscustomobject]@{ Name = $_.Name Count = $_.Count MemoryMB = [math]::Round(($_.Group | Measure-Object WorkingSet64 -Sum).Sum / 1MB) }} | Sort-Object MemoryMB -Descending | Select-Object -First 10Watch it live
Section titled “Watch it live”while ($true) { $os = Get-CimInstance Win32_OperatingSystem "{0:HH:mm:ss} available: {1:N1} GB" -f (Get-Date), ($os.FreePhysicalMemory / 1MB) Start-Sleep -Seconds 2}Stop it with Ctrl+C.
Page file
Section titled “Page file”Get-CimInstance Win32_PageFileUsage | Select-Object Name, AllocatedBaseSize, CurrentUsage, PeakUsageValues are in MB. If CurrentUsage stays high, the machine is short of RAM.
See also
Section titled “See also”- The Linux version: Free memory