ubuntu系统交换分区swap的作用,增加与优化

最近因为服务器有时候会因为各种原因而把内存占用满,导致ssh都连接不上,只能通过阿里云的后台来重启服务器。后来发现可以增加swap交换空间来避免这种情况,然后就了解了一下swap空间。

1.在网上找到的文档解释

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.
Linux 把物理内存划分作称为分页(Page)的内存区块。内存交换是一个内存分页被复制到一个预配置的称为 swap 空间的硬盘空间里的过程,以此来释放内存分页。物理内存与这个 swap 空间的共同大小称为可用的虚拟内存量。