[lkml]   [2004]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [2.4.26] overcommit_memory documentation clarification
    On Sun, 9 May 2004, Vincent Lefevre wrote:

    > Hi,
    > The documentation of overcommit_memory in Documentation/sysctl/vm.txt
    > should be clarified, as with the following simple program, malloc()
    > never returns 0 on an official 2.4.26 kernel, even if overcommit_memory
    > has been set to 0. Running it has the effect of having random processes
    > killed, and eventually this process itself.

    What made you think that malloc would return 0 if the system
    was "out of memory??" Malloc will return NULL, which is not 0 BTW,
    if you are out of address-space or have corrupted it by writing
    past a previous allocation. Malloc's return value is a void *. It
    should be compared against NULL, not zero.

    When malloc() needs new "memory". It just asks the kernel to
    set the new break address or, in the case of mmap() mallocs, asks
    to extend a mapped region. Until somebody actually uses those
    regions, you haven't used any memory. So there is no way for
    malloc() to "know" ahead of time.

    If you run a malloc() bomb from the root account you should
    end up killing off a lot of processes. If you run it from
    a normal user account, and you have set the user's resource
    quotas properly, only the user should get into trouble.

    Dick Johnson
    Penguin : Linux version 2.4.26 on an i686 machine (5557.45 BogoMips).
    Note 96.31% of all statistics are fiction.

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:03    [W:0.019 / U:7.716 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site