Daniel Standage
Daniel Standage

Reputation: 8304

Determine available memory in pure Python

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.

Upvotes: 1

Views: 2316

Answers (1)

ajsalkeld
ajsalkeld

Reputation: 136

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.

Upvotes: 3

Related Questions