Windows - Commit Size vs Virtual Size

前端 未结 3 2047
猫巷女王i
猫巷女王i 2020-12-13 02:12

i would like to know the exact difference between Commit Size (visible in the Task Manager) and Virtual Size (visible in SysIntern

相关标签:
3条回答
  • 2020-12-13 02:48

    Memory can be reserved, committed, first accessed, and be part of the working set. When memory is reserved, a portion of address space is set aside, nothing else happens.

    When memory is committed, the operating system guarantees that the corresponding pages could in principle exist either in physical RAM or on the page file. In other words, it counts toward its hard limit of total available pages on the system, and it formally creates pages. That is, it creates pages and pretends that they exist (when in reality they don't exist yet).

    When memory is accessed for the first time, the pages that formally exist are created so they truly exist. Either a zero page is supplied to the process, or data is read into a page from a mapping. The page is moved into the working set of the process (but will not necessarily remain in there forever).

    Every running process has a number of pages which are factually and logically in RAM, that is these pages exist, and they exist "officially", too. This is the process' working set.
    Further, every running process has pages that are factually in RAM, but do not officially exist in RAM any more. They may be on what's called the "standby list" or part of the buffer cache, or something different. When these are accessed, the OS may simply move them into the working set again.
    Lastly, every process has pages that are not in RAM at all (either on swap or they don't exist yet).

    Virtual size comprises the size of all pages that the process has reserved.

    Commit size only comprises pages that have been committed.

    That is, in layman terms, "virtual size" is pretty much your own problem, and only limited by the size of your address space, whereas "commit size" is everybody's problem since it consumes a global limited resource (RAM plus swap). It therefore affects other processes.

    0 讨论(0)
  • 2020-12-13 02:51

    Virtual size is the size of the process's virtual address space.

    When allocating memory, you can request an address range without actually committing memory behind it. Those address do not point to physical memory until a second allocation call is used to commit them.

    Read more on VirtualAlloc. Linux has the mmap function that does the same thing.

    0 讨论(0)
  • 2020-12-13 02:57

    Commit size is the amount of space reserved in the paging file for the process. Used when its pages need to be swapped out to make room in RAM for other processes.

    And yes, the virtual memory size will be larger since it includes the pages that are not backed by the paging file. At least the code and resource sections in the EXE and non-relocated DLLs. When necessary, those pages can simply be discarded and reloaded from the file. All the operating system DLLs fit this category. Additionally any memory-mapped files used by the process. SysInternals' VMMap utility can give insight.

    0 讨论(0)
提交回复
热议问题