7

I saw this question - What's the difference between "virtual memory" and "swap space"?

Here it is mentioned that virtual memory = RAM space + disk space - which the process can use.

So what can be the maximum size of Virtual memory ?

Is Max(Virtual Memory) = Disk space + RAM space - OS space (on RAM and Disk) ?

Community
  • 1
  • 1
Adon Smith
  • 1,849
  • 7
  • 19
  • 19
  • "*virtual memory = RAM space + disk space - which the process can use*". That's just completely wrong, and the other answer that says that is wrong too. Consider a 64-bit OS with 4GB of RAM and a process that memory maps a 1GB file 100 times, using 100GB of virtual memory. There is no way to add the RAM space, disk space, OS space, or anything else to get the 100GB of virtual memory the process would be using. – David Schwartz Aug 05 '17 at 04:30

3 Answers3

5

Virtual memory is not limited by size of memory pointers in the machine, virtual memory limits are not the same as addressing memory space. More virtual memory than available in your pointer-based address space using paging can be addressed

Virtual memory upper limits are set by the OS: eg. 32-bit Windows the limit is 16TB, and on 64-bit Windows the limit is 256TB.

Max limitation is physical disk space.

To determine how much virtual memory you need, since the user's system contains the different amount of RAM, it is based on the system. By default, the OS will set the appropriate size for Virtual Memory. The default and appropriate size of Virtual Memory is:

<Amount_Of_System_Memory> * 1.5 = <Default_Appropriate_Size_Of_Virtual Memory> 

Personally speaking, to maintain the good overall system performance, you should be using the default size of actual size for Virtual Memory and the triple the value of the size of the main memory for the maximum size of Virtual Memory.

RicoRicochet
  • 2,249
  • 9
  • 28
  • 53
  • sorry i didn't get it , you said virtual memory can be more than disk space + ram space , on the other hand you said "Max limitation is physical disk space." ? – Adon Smith Jan 14 '15 at 07:14
  • no no, virtual memory can not be greater than disk + ram, that is not physically possible :) i just said that more memory space can be used as virtual memory than the pointer based space. you can read this link http://blogs.msdn.com/b/ericlippert/archive/2009/06/08/out-of-memory-does-not-refer-to-physical-memory.aspx which will clear your doubt that "out of memory" does NOT mean physical disk space. – RicoRicochet Jan 14 '15 at 07:58
  • See i still it didn't get you ... please explain it in more simple way :) ... I am very new to OS. – Adon Smith Jan 15 '15 at 09:40
  • 2
    @RicoRicochet Virtual memory can be much greater than disk + RAM. Consider a 64-bit system with a 200 GB disk and 4 GB of RAM. Then imagine 100 processes each read-only memory-map the same 10 GB file, using in total 1 TB of virtual memory. 1 TB is much greater than 200 GB plug 4 GB. – David Schwartz Aug 05 '17 at 04:32
1

Theoretical Limits:

The starting point is the size of a virtual address. Generally 32-bits give a theoretical maximum of 2^32 virtual addresses.

Some systems divide the virtual address space in to dedicated regions (e.g., user and system). The VAX divided the address space into 4 regions (user, stack, system, reserved/unusable 1/4th of the address space).

From there . . .

Configuration Limits:

Most systems may impose a limit on the size of the user page table. This may be per user or a system limit. That restricts the size of the address space.

From there . . .

Runtime Limits:

The size of the available paging areas limit the maximum virtual address space a point in time.

user3344003
  • 20,574
  • 3
  • 26
  • 62
  • But isn't the 2^32 limit is actually limit for each process separately (and therefore, should be consider as a total virtual memory limit in system ) ? – ransh Nov 06 '19 at 11:27
0

Virtual memory management technique which help us to use secondary memory as it was a part of main memory.  

Virtual memory frees up RAM by swapping data that has not been used recently over to a storage device, such as a hard drive or solid-state drive (SSD).

So it limits the maximum size of the virtual memory equal to the maximum physical secondary memory we have.  

Why do we need Virtual Memory:

As we can't load the whole data into the ram and we have limited space there, so we have a page table in the ram which maps the address of the data in secondary memory in the page table, So on demand of the program, we swap-in and swap-out the data between RAM and secondary memory.

This technique is called the virtual memory. we don't have actual memory in ram but we still can have a reference of data in secondary memory which can be loaded and unloaded based on the need.

Arpan Saini
  • 4,623
  • 1
  • 42
  • 50