Virtual Memory and processes
The application itself gets to decide what it wants in virtual memory (within some restrictions). By default that will be the code it run and the memory it uses. The application can also request files to be mapped into memory, or that memory gets shared with another application.

Then the kernel will decide which parts of virtual memory are loaded in RAM based on various factors like: how much ram is available; how much is needed by other processes; how recently a region of virtual memory was accessed, ...