It mainly depends on the architecture (32 bit, 64 bit, etc.). This simplified explanation of things is very , but the so-called "architecture" limits the size of the virtual address space. For example, a 32-bit architecture allows addressing memory addresses of 2 ^ 31.
RAM size limits the amount of physical memory that can be used, but not the virtual address space. (perhaps the hard drive can be used to expand the available physical memory)
In any case, I recommend reading the wiki page on virtual memory
source share