I have been asked in an interview if virtual memory is infinite? I answered saying that it is not infinite. Then the interviewer asked the explanation and what I suggested was t
If nothing else then virtual memory is going to be limited by the amount of disk space available, this sadly is far from infinite.
The size of virtual storage is limited by the addressing scheme of the computer system and by the amount of secondary memory available and not by actual number of main memory locations.
For example :- Even if you had 20 TB of secondary memory, it doesn't mean that virtual memory can be 20TB. It is restricted by your computer architecture.
You were right to say, no, it's not infinite. Addressable virtual memory is limited by architecture address space. For further info see virtual memory.
First of all, forget the idea that virtual memory is limited by the size of pointers on your machine.
Virtual memory limits are not the same as addressing space. You can address more virtual memory than is available in your pointer-based address space using paging.
For an excellent overview, which addresses various misconceptions, see the following:
http://blogs.msdn.com/b/ericlippert/archive/2009/06/08/out-of-memory-does-not-refer-to-physical-memory.aspx
At the very least, the size of virtual memory is limited by the size of pointers on given platform (unless it has near/far pointers and non-flat memory model). For example, you cannot address more than about 2^32 (4GB) of memory using single 32-bit pointer.
In practice, the virtual memory must be backed up with something eventually -- like a pagefile on disk -- so the size of storage enforces a more practical limit.
Virtual memory is the summation of RAM and available hard disk space in most cases. As the summation is a countable number, it can't be infinity.