Available and used System Memory in Python?

PythonOperating SystemCross Platform

Python Problem Overview


> Possible Duplicate:
> How to get current CPU and RAM usage in Python?

How can I get the available and currently used memory from Python? It need to be cross-platform and at least work on at least Windows, Mac OS X and Linux.

I'd like to report the user in my application that he doesn't have enough memory free to proceed and do the next operation.

Python Solutions


Solution 1 - Python

You should take a look to psutil :

>>> import psutil
>>> psutil.virtual_memory()
svmem(total=16717422592, available=5376126976, percent=67.8, used=10359984128, free=1831890944, active=7191916544, inactive=2325667840, buffers=525037568, cached=4000509952, shared=626225152)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohan DahlinView Question on Stackoverflow
Solution 1 - PythonCédric JulienView Answer on Stackoverflow