掉掉掉掉是什么意思?

时间:2015-10-29 11:28:19

标签: linux ubuntu operating-system

在许多情况下的linux机器中,我们可能会遇到错误。究竟是什么意思。它是否类似于颠簸?正在耗尽空间和耗尽交换是类似的条款?我们怎样才能找到解决这类错误的方法?

2 个答案:

答案 0 :(得分:4)

swap是RAM的辅助(基于磁盘)存储:如果您的应用程序占用太多内存,则RAM的某些部分换出(移动)到硬盘,为新的内存请求腾出空间。 (这是假设在不久的将来不需要换出的内存;如果应用程序需要再次访问它,内存将再次交换(移回到RAM),可能首先触发另一个存储区的交换

交换通常相当慢,因为它涉及在RAM和硬盘之间移动更大的数据块,并且所有应用程序必须等到它完成才能继续。因此,它是一种避免内存不足崩溃的安全措施,但您应尽量避免触发交换。

现在交换空间本身可以是文件或整个分区,但无论如何它们的大小也有限(由它们所在的分区大小定义,或受操作系统限制)。 / p>

因此,如果你需要换掉大量内存(或者有一个小的交换空间),你迟早会用完交换

基本上有两种方法可以解决问题:

  • 让您的交换空间更大
  • 使您的应用程序消耗更少的内存

扩展交换空间

  • 首先,尝试为系统添加更多RAM。您拥有的RAM越多,系统需要更换内存的可能性就越小。

如果这没有帮助(或者不可能),您可能需要扩展实际可用的交换空间:

  • 首先使用mkswap创建一个新的交换区域(文件或磁盘分区)。
  • 然后使用swapon启用交换空间。
  • 您还可以通过在fstab文件中添加条目来保持更改。

但实际上这可能会让你的“掉线”问题出现一段时间,所以请继续阅读:

减少内存消耗

今天的电脑有足够的内存。 除非您正在处理非常大的数据集或并行运行非常多内存饥饿的应用程序,否则您不太可能耗尽RAM和/或交换空间。

除非,即你的某个应用程序有memory leak并且消耗了未绑定的内存量。

尝试找出哪些应用程序占用了所有内存,并检查它们是否正在泄漏资源。

答案 1 :(得分:1)

Swap space is an area on disk that is used to store processes when they are moved out of memory. In ye olde days before virtual memory, this was the means of making room for multiple users.

A page file is an area on disk that is used to implement virtual memory.

Swapping => Moving entire processes in and out of memory. Paging => Moving individual pages in and out of memory.

Some systems have used both swap and page files but the trend now is just to have a page file.

Page files need to be contiguous for efficiency purposes, something not possible on the historical unix file system. Many unix variants use a disk partition rather than a file. This usually called a "Swap Partition" in unix-land because Unix originally ran on PDPs that did not support virtual memory. Therefore they used swapping rather than paging and the name stayed on.

The problem of running out of swap depends upon whether you are really swapping or paging. In a virtual memory system all user user memory has to be mapped to a file. Often this is a combination of the executable file and the page file. The executable file is used to page static memory (code, data) while the page file pages dynamic memory. The size of the page file is then one of the limitations on the amount of virtual memory a process can have EVEN IF PHYSICAL MEMORY IS AVAILABLE. Virtual memory requires there to be a disk space for all memory pages. Increasing physical memory does not solve running out of paging space.

It is unlikely you are encountering a swapping system these days. There are some page file and swap file systems around. In a swapping system, lack of space is generally a problem of having too many jobs running around. You can increase physical memory but most swapping systems support 1,2, 4, maybe 8 MB (not GB).