為什麼 free 很小,Linux 卻還能開程式?看懂 MemFree 與 MemAvailable / Why a Tiny free Column Does Not Mean Linux Cannot Start Programs
現象:free 很小,不代表開不了程式 / A tiny free column is not “cannot start” 假設你在 Linux 終端機打出 free,free 欄只剩幾十 MB,used 卻佔了一大半。很容易先想到「記憶體爆了,得重開或加 RAM」。先停一下:這個畫面常常不是實體記憶體已經沒了,而是把「完全沒被用到的頁」,當成「還能開新程式的空間」。 Suppose you run free in a Linux terminal and the free column is down to a few dozen megabytes, while used takes most of the row. It is easy to jump to “memory is exhausted; reboot or add RAM.” Pause first: that picture often does not mean physical memory is gone. It means idle pages have been mistaken for the space still available to start a new program. /proc/meminfo 的 MemFree,依 Linux 7.4-rc1 的 proc 文件,是目前的 free RAM;在 highmem 系統上,它是 LowFree 與 HighFree 的和。它變小,只表示幾乎沒有完全閒置的頁。核心會把讀過的檔案留在記憶體裡,這份快取叫 page cache,也就是頁快取。那些頁還佔著 RAM,所以 MemFree 下降,但它們不是某個程式私有、放不掉的佔用。[1] In Linux 7.4-rc1’s proc documentation, MemFree in /proc/meminfo is the current free RAM; on highmem systems it is the sum of LowFree and HighFree. A small value only means there are almost no completely idle pages. The kernel keeps files it has re...