无论是windows系统还是linux系统,除了物理内存外,都还有一个虚拟内存。在linux上,虚拟内存被称为swap space。过去以来,虚拟内存的大小应该是物理内存的两倍,但是最近几年来,物理内存的大小至少都有了好几个GB,如果16G内存用32G的swap岂不是太占用硬盘空间?
下图是虚拟内存和交换空间的映射关系,虚拟内存的存在,可以提高电脑的运行速度,所以其存在很有意义。
我们看看redhat的官方答复是怎么说的:
Amount of RAM in the system 物理内存 | Recommended swap space建议的交换空间大小 | Recommended swap space if allowing for hibernation如果开启休眠功能建议的交换空间大小 |
---|---|---|
⩽ 2GB | 2 times the amount of RAM | 3 times the amount of RAM |
> 2GB – 8GB | Equal to the amount of RAM | 2 times the amount of RAM |
> 8GB – 64GB | At least 4 GB | 1.5 times the amount of RAM |
> 64GB | At least 4 GB | Hibernation not re |