How to get Windows physical RAM using python?

Tim Golden tim.golden at
Thu Jul 31 10:28:25 CEST 2003

BranimirPetrovic at (Branimir Petrovic) wrote in message news:<b11d1191.0307301601.67450ca3 at>...
> "Martin v. Löwis" <martin at> wrote in message news:<bg920a$9pt$05$1 at>...
> > Python can't get you Windows physical RAM. You have to order RAM
> > from a manufacturer or reseller if Windows needs more RAM :-)
> > 
> > Regards,
> > Martin
> "Easy" way to get to physical RAM on Windows is via WMI objects.

And here's how you'd do it in Python:

1) Get WMI module from

2) Do something like this:

import wmi

computer = wmi.WMI ()
for i in computer.Win32_ComputerSystem ():
  print i.Caption, "has", i.TotalPhysicalMemory, "bytes of memory"

Obviously you can fiddle around with Megabytes and Gigabytes and so on
if you need to. The loop is a slight hack: you obviously only have one
computer system, but this interface to WMI always returns a list
(albeit of one value).


More information about the Python-list mailing list