top命令
字段解析
RES
(Resident Memory Size): A subset of the virtual address space (VIRT) representing the non-swapped physical memory a task is currently using. It is also the sum of the RSan, RSfd and RSsh fields. 正在使用没有被SWAP的内存.- RES=CODE+DATA
SHR
: Shared Memory Size (KiB): A subset of resident memory (RES) that may be used by other processes. It will include shared anonymous pages and shared file-backed pages. 和其他进程共享的内存SWAP
: Swapped Size (KiB): The formerly resident portion of a task's address space written to the swap file when physical memory becomes over committed.VIRT
: The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.- VIRT=RES+SWAP
- 实际占用的物理内存=RES-SHR
参考资料 1. https://javawind.net/p131 2. https://man7.org/linux/man-pages/man1/top.1.html