Linux swap分区及作用详解

道锋潜鳞
2020-03-28 / 0 评论 / 28 阅读 / 正在检测是否收录...

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 空间的共同大小称为可用的虚拟内存量。

在这里,保留 swap 分区有两个重要的原因。

其一,当物理内存不足以支撑系统和应用程序(进程)的运作时,这个 swap 空间可以用作临时存放使用率不高的内存分页,把腾出的内存交给急需的应用程序(进程)使用。

再有,即使你的机器拥有足够多的物理内存,也有一些程序会在它们初始化时残留的极少再用到的内存分页内容转移到 swap 空间,以此让出物理内存空间。对于有发生内存泄漏几率的应用程序(进程),swap 空间更是重要,因为谁也不想看到由于物理内存不足导致系统崩溃。

0

评论 (0)

取消