Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
Maybe mem can't handle 192 GB of RAM? –  iglvzx Apr 30 '12 at 5:51
2  
Or maybe they just couldn't figure out how to make it work. –  Ignacio Vazquez-Abrams Apr 30 '12 at 5:54
2  
@iglvzx: Seeing that mem.exe is a 16-bit MS-DOS executable, you are probably right. –  grawity Apr 30 '12 at 7:58
1  
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
add comment

1 Answer

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

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394587%28v=vs.85%29.aspx

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: " & _
        objOperatingSystem.FreePhysicalMemory
Next

PowerShell method

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394587%28v=vs.85%29.aspx

# Get-FreeMemory.ps1
# Sample using PowerShell
# 1st sample from http://msdn.microsoft.com/en-us/library/aa394587
# 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
2  
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
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.