If you are mostly familiar with Windows computers, you may find the way your Linux dedicated server uses memory to be odd or even alarming. When I first started using Linux on a server, it was a bit disconcerting to see Linux use up all of the available RAM. This is much different than the way Windows handles RAM usage.
Operating systems typically use two types of memory: physical memory and virtual memory. Physical memory is the actual physical space found on computer hardware. It primarily refers to system RAM (Random-Access Memory), but may also refer to memory on other devices, such as processors, onboard chips, and even graphics cards. On a server, however, it exclusively means system RAM modules.
Virtual memory is actually disk space set aside to provide additional cache for system and user applications. Windows uses a file called “pagefile.sys” that stores virtual memory. It uses the virtual memory even if there is some system RAM still available, and is constantly reading and writing the file. The extent to which the pagefile is used, often varies depending on the application. The total amount of virtual memory is technically the combined space available in physical memory and the pagefile.
Linux uses a completely separate partition called “swap” to store virtual memory. Unlike Windows, swap is basically a last resort. If you have 4GB of system RAM, Linux may never touch the swap partition. It will load applications completely into the RAM and even cache data from those applications in the physical RAM. As a result, the applications should run very quickly and should restart faster, even after you have exited them.
By default, many Linux distributions will create a swap partition that is equal in size to the amount of physical memory. With physical memory over 2GB, however, most of that swap space will probably remain empty. Although it was a common practice at one time to create a swap partition twice the size of the physical memory, this is no longer practical or necessary, especially when dealing with higher-end servers with 8, 16, or even 32 GB of RAM.