312
RSS is the Resident Set Size and is used to show how much memory is allocated to that process and is in RAM. It does not include memory that is swapped out. It does include memory from shared libraries as long as the pages from those libraries are actually in memory. It does include all stack and heap memory.
RSS是常驻设置大小,用于显示为该进程分配了多少内存,并在RAM中。它不包括被交换出去的内存。它确实包括共享库中的内存,只要这些库中的页面实际上在内存中。它包括所有堆栈和堆内存。
VSZ is the Virtual Memory Size. It includes all memory that the process can access, including memory that is swapped out, memory that is allocated, but not used, and memory that is from shared libraries.
VSZ是虚拟内存大小。它包括进程可以访问的所有内存,包括交换出去的内存、分配但不使用的内存和来自共享库的内存。
So if process A has a 500K binary and is linked to 2500K of shared libraries, has 200K of stack/heap allocations of which 100K is actually in memory (rest is swapped or unused), and it has only actually loaded 1000K of the shared libraries and 400K of its own binary then:
如果处理一个有500 k二进制和共享库与2500 k,200 k的堆栈和堆分配的100 k实际上是在内存中(其他交换或未使用),实际上它只有加载共享库的1000 k和400 k的二进制文件:
RSS: 400K + 1000K + 100K = 1500K
VSZ: 500K + 2500K + 200K = 3200K
Since part of the memory is shared, many processes may use it, so if you add up all of the RSS values you can easily end up with more space than your system has.
由于内存的一部分是共享的,所以许多进程可能会使用它,所以如果您将所有的RSS值加起来,您很容易得到比系统拥有的更多的空间。
The memory that is allocated also may not be in RSS until it is actually used by the program. So if your program allocated a bunch of memory up front, then uses it over time, you could see RSS going up and VSZ staying the same.
被分配的内存也可能在程序实际使用之前不在RSS中。如果你的程序预先分配了一堆内存,然后随着时间的推移使用它,你可以看到RSS在增加VSZ保持不变。
There is also PSS (proportional set size). This is a newer measure which tracks the shared memory as a proportion used by the current process. So if there were two processes using the same shared library from before:
还有PSS(比例设置大小)。这是一个更新的度量,它跟踪共享内存作为当前进程使用的比例。因此,如果以前有两个进程使用相同的共享库:
PSS: 400K + (1000K/2) + 100K = 400K + 500K + 100K = 1000K
Threads all share the same address space, so the RSS, VSZ and PSS for each thread is identical to all of the other threads in the process. Use ps or top to view this information in linux/unix.
线程都共享相同的地址空间,因此每个线程的RSS、VSZ和PSS与进程中的所有其他线程相同。在linux/unix中使用ps或top查看这些信息。
There is way more to it than this, to learn more check the following references:
还有比这更重要的事情,去了解更多关于以下参考文献的信息:
- http://manpages.ubuntu.com/manpages/en/man1/ps.1.html
- http://manpages.ubuntu.com/manpages/en/man1/ps.1.html
- https://web.archive.org/web/20120520221529/http://emilics.com/blog/article/mconsumption.html
- https://web.archive.org/web/20120520221529/http:/ /emilics.com/blog/article/mconsumption.html
Also see:
还看到:
- A way to determine a process's "real" memory usage, i.e. private dirty RSS?
- 确定进程“真实”内存使用情况的一种方法,即私有的脏RSS?