views:

9100

answers:

5

Virtual memory from a computer size perspective is

[a way to make the program] think it has a large range of contiguous addresses; but in reality the parts it is currently using are scattered around RAM, and the inactive parts are saved in a disk file. (Wikipedia)

I would interpret VM Size in the Windows Task manager as either the total addressable virtual memory space or the amount of memory the process is currently using in the virtual memory space.

But in the Task Manager the WM Size is in many cases less than Mem Usage, which should be amount of RAM the process is using. Therefor I guess that WM Size means something else?

A: 

How about a coding horror post to answer this: http://www.codinghorror.com/blog/archives/000393.html

"VM Size: How much of the processes' less frequently used memory has been paged to disk."

Swingley
Actually, see Mike Dimmick's comment on that post: "You're wrong on VM Size. It's the total of all private (not shared) bytes allocated by this process, whether currently in physical memory or not... "
Bradley Grainger
A: 

The amount of memory mapped into that process' address space. This can include shared memory mappings.

In a process there will be sections of the memory space for each shared object (DLL) that is part of it, as well as some memory for stack, and areas allocated by the process itself.

For example looking at the memory map of a cat command on my system I can see its memory mappings. In this case I use cat /proc/self/maps to investigate the cat process itself. Mapped into its virtual memory is the binary itself, some heap, locale information, libc (with various permission flags), ld.so (the dynamic linker), stack, vdso and vsyscall sections and some anonymous mappings (mapped pages with no backing file).

00400000-00408000         r-xp      /bin/cat
00607000-00608000         rw-p      /bin/cat
008ac000-008cd000         rw-p      [heap]
7fbd54175000-7fbd543cf000 r--p      /usr/lib/locale/locale-archive
7fbd543cf000-7fbd54519000 r-xp      /lib/libc-2.7.so
7fbd54519000-7fbd54718000 ---p      /lib/libc-2.7.so
7fbd54718000-7fbd5471b000 r--p      /lib/libc-2.7.so
7fbd5471b000-7fbd5471d000 rw-p      /lib/libc-2.7.so
7fbd5471d000-7fbd54722000 rw-p
7fbd54722000-7fbd5473e000 r-xp      /lib/ld-2.7.so
7fbd5491d000-7fbd5491f000 rw-p 
7fbd5493a000-7fbd5493d000 rw-p
7fbd5493d000-7fbd5493f000 rw-p      /lib/ld-2.7.so
7fff5c929000-7fff5c93e000 rw-p      [stack]
7fff5c9fe000-7fff5c9ff000 r-xp      [vdso]
ffffffffff600000-ffffffffff601000 r-xp    [vsyscall]

For each mapping, subtract the start address from the end address to determine its size, for example the [stack] line: 0x7fff5c9ff000 - 0x7fff5c9fe000 = 0x1000. In decimal, 4096 bytes - a 4 kiB stack.

If you add up all these figures, you'll get the process' virtual memory (VM) size.

VM size is not a reliable way to determine how much memory a process is using. For instance there will only be one copy of each of the read-only /lib/libc-2.7.so maps in physical memory, regardless of how many processes use it.

Ted Percival
A: 

What's the correct answer about VM Size?

  • In Coding Horror

    How much of the processes' less frequently used memory has been paged to disk.

  • In Comment of Coding Horror

    You're wrong on VM Size. It's the total of all private (not shared) bytes allocated by this process, whether currently in physical memory or not. It's a better value for tracking whether you have a memory leak than 'Mem Usage'. The same value is available in Performance Monitor as 'Process: Private Bytes'.

  • In MSDN

    Virtual Memory Size : The amount of virtual memory, or address space, committed to a process.

I am confusing what is corrent.

Simon Kim
+6  A: 

It's the total of all private (not shared) bytes allocated by this process, whether currently in physical memory or not.

See also An introductory guide to Windows Memory Management or Commit Charge Wikipedia article

For a developer watching process state like this I would recommend to install SysInternals Process Explorer and to use it instead of the default Task Manager. This value is called "Private Bytes" in it.

Suma
thx for the link to SysInternals Process Explorer
jedierikb
A: 

I can't see VM size in the Windows task manager, Whatup Gold has a VM size in its task manager - do you mean that? in this case i beleive it relates to the total amount available to the VM

Lewis