psutil virtual memory units of measurement?

user3063850 picture user3063850 · Feb 15, 2014 · Viewed 14.1k times · Source

When running psutil.virtual_memory() i'm getting output like this:

    >>psutil.virtual_memory()
    vmem(total=8374149120L, available=1247768576L)

But what unit of measurement are these values? The documentation simply claims that its the "total physical memory available" but nothing more. I'm trying to translate it into values that the user can actually relate to (ie GBs).

Thanks in advance

Answer

ha2ar6 picture ha2ar6 · Aug 29, 2014

why not use bit shift operator: if you want to display in human readable way, just like this!

values = psutil.virtual_memory()

display in MB format

total = values.total >> 20

display in GB format

total = values.total >> 30