在 Python 应用程序中,如何以跨平台的方式获取系统的 RAM 总量以及当前可用的内存量?
理想情况下,空闲 RAM 的数量应该只考虑实际可以分配给 Python 进程的物理内存。
最佳答案
你试过了吗SIGAR - System Information Gatherer And Reporter ? 安装后
import os, sigar
sg = sigar.open()
mem = sg.mem()
sg.close()
print mem.total() / 1024, mem.free() / 1024
希望对你有帮助
关于python - 从 Python 中获取总内存/空闲内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1204378/