I am aware of the psutil package which provides (along with many other things) a way to access information about system memory, including the amount of available memory (psutil.virtual_memory().available
). How would I go about querying available memory in a pure Python implementation? The solution would need to work for UNIX-like systems, including Linux, OS X, and so on.
Asked
Active
Viewed 2,277 times
1

Daniel Standage
- 8,136
- 19
- 69
- 116
-
You can probably read it from `/proc/meminfo` – GWW Jul 05 '16 at 16:32
-
How is the edit @BhargavRao? – Daniel Standage Jul 05 '16 at 16:32
-
@Daniel, That's a good edit, But the line *How would I go about querying available memory in a pure Python implementation?* would make it too broad. Google it, try the first one add the results to the post and it will make your post a good question. Related reads are [ask] and [mcve]. – Bhargav Rao Jul 05 '16 at 16:36
1 Answers
3
Already sort of answered here, although this method includes reading the /proc/meminfo
file, which comes on most Linux/Unix distributions.
As per other operating systems, it looks like psutil is your only option, unless Windows has something similar.
Update:
For OS X/macOS, something similar may be possible, using vm_stat
, like the python script in this answer.
-
1Windows support is not a concern, but `/proc/meminfo` is unavailable on OS X. – Daniel Standage Jul 05 '16 at 16:40