* 2GB swap space for 4GB of RAM or less.
* 4GB swap space for 4-16GB of RAM
* 8GB swap space for 16-64GB of RAM
* 16GB swap space for 64-256GB of RAM
* 32GB swap space for 256-512GB of RAM
But, Here is some-more detailed information about calculating swap space,
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
M = Amount of RAM in GB, and S = Amount of swap in GB, then
Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).