python - 从 Python 中获取总内存/空闲内存

标签 python wxpython

在 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/

相关文章:

python - 了解 Django 中的 View 评估

python 现在,接下来,n 次迭代

python - wxPython - Ubuntu 上的 "Uknown accel modifier: num/numpad"

python - 为什么我的 wxPython 小部件的格式会出现问题?

python - 在同一轴上重新绘制数据时如何重置 NavigatonToolbar "history"?

python - wxPython:如何在多行 TextCtrl 上监听 EVT_CHAR 事件?

python - 在 ListCtrl 中放置一个按钮 - wxPython

python - 将行写入 CSV 文件而不添加引号

python - 如何在 Pandas 中使用条件进行计算?

python - 在wxpython的列上排序?