本文介绍了在Linux中查找进程的内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查找特定进程的当前内存使用情况.到目前为止,我在网上找到的每本指南都提供了有关如何获得使用率(占总内存的百分比)的说明.我希望thr进程的ram usae为离散值(即以兆字节为单位).
I am trying to find the current memory usage of a particular process. Every guide I've found online so far gives instructions on how to get the usage as a percentage of total memory. I want thr process' ram usae as a discrete value (i.e. in megabytes).
推荐答案要仅获取单个感兴趣的内存使用量,请尝试:
To only get a single memory-usage number of interest, try:
ps -o rss= $pid # resident set in kbytes; e.g., 2461016 ps -o vsz= $pid # virtual size in kbytes; e.g., 1048要转换为MB(四舍五入为整数,请根据需要进行调整),请尝试以下操作:
To convert to MB (rounded to an integer, adjust as needed), try something like:
ps -o rss= $pid | awk '{printf "%.0f\n", $1 / 1024}' # e.g., 1更多推荐
在Linux中查找进程的内存使用情况
发布评论