我有一个完全在 rootfs 上的 linux(据我所知是 ramfs 的一个实例)。没有硬盘,也没有交换。我得到了一个不断泄漏内存的进程。虚拟内存最终增长到物理内存大小的 4 倍,如顶部所示。我不明白发生了什么。rootfs 应该只占用 RAM,对吧?如果我没有要交换的磁盘,虚拟内存如何增长到物理内存的 4 倍?
问问题
173 次
1 回答
1
并非所有分配的内存都必须由块设备支持;glibc 人认为这种行为是一个错误:
BUGS
By default, Linux follows an optimistic memory allocation
strategy. This means that when malloc() returns non-NULL
there is no guarantee that the memory really is available.
This is a really bad bug. In case it turns out that the
system is out of memory, one or more processes will be killed
by the infamous OOM killer. In case Linux is employed under
circumstances where it would be less desirable to suddenly
lose some randomly picked processes, and moreover the kernel
version is sufficiently recent, one can switch off this
overcommitting behavior using a command like:
# echo 2 > /proc/sys/vm/overcommit_memory
See also the kernel Documentation directory, files
vm/overcommit-accounting and sysctl/vm.txt.
于 2011-04-10T09:48:46.277 回答