Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
Walleve0
V2EX  ›  Linux

询问 VIRT 与 SWAP 的问题

  •  
  •   Walleve0 · Oct 28, 2015 · 2862 views
    This topic created in 3859 days ago, the information mentioned may be changed or developed.

    alt text
    求问 为什么 SWAP 为 0 , VIRT 值还能那么大?

    4 replies    2015-10-29 13:46:10 +08:00
    owwlo
        1
    owwlo  
       Oct 28, 2015
    &> man top 得到的解答:

    o: VIRT -- Virtual Image (kb)
    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.
    ryd994
        2
    ryd994  
       Oct 29, 2015
    linux 下 virt 和 windows 的虚拟内存不是一回事。
    只是代表用了多少虚地址地址空间而已。包括所有用的内存、 swap 、 mmap 等
    https://en.wikipedia.org/wiki/Page_table
    一般 virt 大小和性能之间没有必然联系
    如果你 mmap 一个超大的文件,即使这个文件并不在内存或 swap ,也计 virt
    mind3x
        3
    mind3x  
       Oct 29, 2015   ❤️ 2
    打个不那么严格的比方:

    你有 100 页白纸;
    你要写一本书,初步准备弄个 1000 页;
    你决定先写这本书的第 10 到第 19 页,和第 510 到 519 页;
    你于是拿出 20 页白纸,在上面画小人,还编上了页码 10-19 和 510-519 。

    这里的 1000 页就是 VIRT ;
    20 页领出来的白纸是 RES ;
    你领出来的 20 页里某一页画了一头猪,你觉得完全可以用到你的另一本书里,这一页就是 SHR 。

    后来你突然觉得不想写 1000 页这么多了,只想写 50 页,页码也重编过,那你新的 VIRT 就是 50 。
    Walleve0
        4
    Walleve0  
    OP
       Oct 29, 2015
    明白了,谢谢各位~! O(∩_∩)O~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   945 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 21:43 · PVG 05:43 · LAX 14:43 · JFK 17:43
    ♥ Do have faith in what you're doing.