/proc/[PID]/smaps (since Linux
2.6.14)
This file shows memory consumption for each of the process's mappings.
For each of mappings there is a series
of lines as follows:
或者
/proc/[PID]/statm
Provides information about memory usage, measured in pages.
拥有子进程的PID号,您可以从proc file-system读取所有信息。使用:
或者
或者,您可以限制子流程可以获取的资源:
当达到给定的虚拟内存限制时,进程将因内存不足而失败。
在生成子进程之前,可以使用Python的resource模块设置限制。
为了进行监视,resource.getrusage()将为您提供所有子进程的摘要信息;如果您想查看每个子进程的信息,可以在其他注释中执行/proc技巧(不可移植但有效),或者在每个子进程之间放置一个Python程序并找出一些通信(可移植,丑陋,稍微有效)。
相关问题 更多 >
编程相关推荐