lkml.org 
[lkml]   [1999]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[test program] for OOM situations
    Hi,

    I've a test program here which can be used to check the differend
    behavor of OOM situations in 2.0, 2.2 and 2.3 kernels.

    The program is quite effective in eating every byte of userspace memory:

    --- empty Thu Jul 1 02:01:49 1999
    +++ mem.c Thu Jul 1 02:02:00 1999
    @@ -0,0 +1,30 @@
    +#include <stdio.h>
    +#include <string.h>
    +
    +#define MEM_MAX 1024 * 1024 * 5
    +
    +main()
    +{
    + long mem_avail = MEM_MAX;
    + char *buf;
    +
    + while(1)
    + {
    + printf("Trying to allocate %ld bytes: ", mem_avail);
    +
    + if ((buf = (char *)malloc((size_t)mem_avail)))
    + {
    + printf(" success!\n");
    + memset(buf, 'X', mem_avail);
    + //sleep(1);
    + }
    + else
    + {
    + printf(" failed :(\n");
    + mem_avail = mem_avail / 2;
    + sleep(1);
    + }
    + }
    +
    + return 0;
    +}
    Result on 2.0.37:
    Runs slowly, eats all mem and keeps running. 'top' can be used to kill it.
    Ctrl-C interrupts the program immediately.

    Result on 2.3.9-pre8
    Runs fast, eats all mem and keeps running. 'top' can be used to kill it.
    Ctrl-C interrupts the program immediately.

    Result on 2.2.{7,10}
    Runs fast, eats all mem and stops. 'top' stops refreshing its display,
    so you need to catch the pid before OOM if you want to kill it. some
    seconds pass from pressing the 'k'-key in top and the 'PID to kill'-prompt.
    Ctrl-C takes quite some time to interrupt the program(if you are lucky).
    Any Comments?

    - Bernd



    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:52    [W:0.020 / U:73.852 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site