我有时会看到基于 Linux 的服务器在不需要时使用交换。特别是当所有空闲内存都用于缓存时。但是现在我的 16GB RAM 专用服务器开始交换,尽管有足够的可用 RAM:
$ free -m
total used free shared buffers cached
Mem: 16029 10035 5994 0 421 8508
-/+ buffers/cache: 1104 14925
Swap: 19322 3 19319
Run Code Online (Sandbox Code Playgroud)
服务器正在运行一个 web 服务器、php 和一个从不使用所有 16GB 的数据库。应该没有必要交换。但是 Linux 仍然这样做。在这种情况下只有 3MB,但这是原则。