The OS
allocates as many virtual pages as necessary to map the sections defined in the executable files.
If another process is already running the same executables then the OS reuses read-only pages at least and if the OS supports "copy-on-write" then it reuses already mapped unaltered read-write pages for a new process. For stacks, heaps, etc., it will reserve the virtual address space, but the pages would be allocated on demand, i.e. when stack grows beyond already mapped space, then the OS allocates more page(s)
The space in a swap file is allocated when the system decides to swap some altered pages of a process out of RAM. This is optimal strategy though, the actual behavior may vary from OS to OS.