且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何找出Linux中哪些进程正在使用交换空间?

更新时间:2023-01-17 23:00:06

运行 top ,然后按 O p Enter .现在,应按交换使用情况对进程进行排序.

Run top then press OpEnter. Now processes should be sorted by their swap usage.

这里是更新,因为我的原始答案没有提供评论中所指出问题的确切答案.从 htop常见问题解答:

Here is an update as my original answer does not provide an exact answer to the problem as pointed out in the comments. From the htop FAQ:

不可能获得已使用交换空间的确切大小 过程. Top通过使SWAP = VIRT-RES来伪造此信息,但是 这不是一个很好的指标,因为其他内容(例如视频内存) 也依靠VIRT(例如:top表示我的X进程正在使用 81M的交换,但它也报告我的系统总体上仅使用2M 交换.因此,我不会在htop中添加类似的Swap列 因为我不知道获取此信息的可靠方法(实际上, 我认为无法获得确切的数字,因为共享 页).

It is not possible to get the exact size of used swap space of a process. Top fakes this information by making SWAP = VIRT - RES, but that is not a good metric, because other stuff such as video memory counts on VIRT as well (for example: top says my X process is using 81M of swap, but it also reports my system as a whole is using only 2M of swap. Therefore, I will not add a similar Swap column to htop because I don't know a reliable way to get this information (actually, I don't think it's possible to get an exact number, because of shared pages).