【问题标题】:What happens if memory leaks on rootfs?如果 rootfs 上的内存泄漏会发生什么?
【发布时间】:2011-04-10 09:44:35
【问题描述】:

我有一个完全在 rootfs 上的 linux(据我所知是 ramfs 的一个实例)。没有硬盘,也没有交换。我得到了一个不断泄漏内存的进程。虚拟内存最终增长到物理内存大小的 4 倍,如顶部所示。我不明白发生了什么。 rootfs 应该只占用 RAM,对吧?如果我没有可交换的磁盘,虚拟内存如何增长到物理内存的 4 倍?

【问题讨论】:

    标签: memory-leaks rootfs


    【解决方案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.
    

    【讨论】:

    • 谢谢!我将阅读 vm/overcommit-accounting 和 sysctl/vm.txt 以了解更多信息。
    猜你喜欢
    • 2011-06-28
    • 2018-06-08
    • 2011-05-13
    • 1970-01-01
    • 2021-08-15
    • 2013-04-01
    • 2016-01-01
    • 2011-10-25
    • 1970-01-01
    相关资源
    最近更新 更多