2011-04-10 94 views
0

我有一个linux完全rootfs(据我所知是一个ramfs实例)。没有硬盘,也没有交换。我得到了一个不断泄漏内存的进程。虚拟内存最终增长到物理内存大小的4倍,如上图所示。我无法理解发生了什么事。 rootfs应该只需要RAM,对吧?如果我没有磁盘交换,虚拟内存如何增长到物理内存的4倍?如果在rootfs上发生内存泄漏,会发生什么情况?

回答

1

并非所有分配的内存都必须由块设备支持; 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. 
+0

Thanks!我将阅读vm/overcommit-accounting和sysctl/vm.txt以了解更多信息。 – 2011-04-10 09:51:53

相关问题