0
我有一個linux完全rootfs(據我所知是一個ramfs實例)。沒有硬盤,也沒有交換。我得到了一個不斷泄漏內存的進程。虛擬內存最終增長到物理內存大小的4倍,如上圖所示。我無法理解發生了什麼事。 rootfs應該只需要RAM,對吧?如果我沒有磁盤交換,虛擬內存如何增長到物理內存的4倍?如果在rootfs上發生內存泄漏,會發生什麼情況?
我有一個linux完全rootfs(據我所知是一個ramfs實例)。沒有硬盤,也沒有交換。我得到了一個不斷泄漏內存的進程。虛擬內存最終增長到物理內存大小的4倍,如上圖所示。我無法理解發生了什麼事。 rootfs應該只需要RAM,對吧?如果我沒有磁盤交換,虛擬內存如何增長到物理內存的4倍?如果在rootfs上發生內存泄漏,會發生什麼情況?
並非所有分配的內存都必須由塊設備支持; glibc-人們認爲這種行爲是一個bug:
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.
Thanks!我將閱讀vm/overcommit-accounting和sysctl/vm.txt以瞭解更多信息。 – 2011-04-10 09:51:53