Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On *nix systems, free displays the total amount of free and used memory in the system. From my research, the DOS mem command is similar, but it is not available on 64-bit versions of Windows 7. Is there a built-in alternative for the mem command?

share|improve this question
What a glaring omission... – Ignacio Vazquez-Abrams Apr 30 '12 at 5:48
Maybe mem can't handle 192 GB of RAM? – iglvzx Apr 30 '12 at 5:51
Or maybe they just couldn't figure out how to make it work. – Ignacio Vazquez-Abrams Apr 30 '12 at 5:54
@iglvzx: Seeing that mem.exe is a 16-bit MS-DOS executable, you are probably right. – grawity Apr 30 '12 at 7:58
mem isn't useful on 32 bit windows either since it only reports the status of the 16 bit dos virtual machine. – psusi Apr 30 '12 at 13:24
up vote 7 down vote accepted

Note that all of these return kilobytes.

wmic method

wmic os get TotalVisibleMemorySize,FreePhysicalMemory

I'm not sure TotalVisibleMemorySize is correct, but it does appear to show physical memory on my system.

VBScript method

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings 
    Wscript.Echo "Available Physical Memory: " & _

PowerShell method

# Get-FreeMemory.ps1
# Sample using PowerShell
# 1st sample from
# Thomas Lee

$mem = Get-WmiObject -Class Win32_OperatingSystem

# Display memory
"System : {0}" -f $mem.csname
"Free Memory: {0}" -f $mem.FreePhysicalMemory

This script produces the following output:

PS C:\foo> .\get-freememory.ps1
  System : COOKHAM8
  Free Memory: 2776988

PowerShell condensed (called from cmd)

powershell.exe -c (Get-WmiObject -Class Win32_OperatingSystem).FreePhysicalMemory
share|improve this answer
As per the specs, TotalVisibleMemorySize gives the amount of memory visible to the OS, which is physical memory minus whatever is reserved by hardware. – Indrek Apr 30 '12 at 9:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .