Re: OOM (HighMem) on linux 2.6.24.2

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Denys Vlasenko
Date: Tuesday, April 1, 2008 - 1:17 am

On Tuesday 01 April 2008 06:57, Peter Zijlstra wrote:

I don't know, but the following definitely works for me:

#include <stdlib.h>
int main() {
    void *p;
    unsigned size = 1 << 20;
    unsigned long total = 0;
    while (size) {
        p = malloc(size);
        if (!p) size >>= 1;
        else {
            memset(p, 0x77, size);
            total += size;
            printf("Allocated %9u bytes, %12lu total\n", size, total);
        }
    }
    printf("Cannot malloc more. Exiting\n");
    return 0;
}

# softlimit -a 12000000 ./oom
Allocated   1048576 bytes,      1048576 total
Allocated   1048576 bytes,      2097152 total
Allocated   1048576 bytes,      3145728 total
Allocated   1048576 bytes,      4194304 total
Allocated   1048576 bytes,      5242880 total
Allocated   1048576 bytes,      6291456 total
Allocated   1048576 bytes,      7340032 total
Allocated   1048576 bytes,      8388608 total
Allocated   1048576 bytes,      9437184 total
Allocated   1048576 bytes,     10485760 total
Allocated    262144 bytes,     10747904 total
Cannot malloc more. Exiting

--
vda
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
OOM (HighMem) on linux 2.6.24.2, Kevin Shanahan, (Wed Mar 19, 5:48 pm)
Re: OOM (HighMem) on linux 2.6.24.2, Jiri Slaby, (Thu Mar 20, 1:44 am)
Re: OOM (HighMem) on linux 2.6.24.2, Peter Zijlstra, (Thu Mar 20, 1:54 am)
Re: OOM (HighMem) on linux 2.6.24.2, Kevin Shanahan, (Thu Mar 20, 3:04 am)
Re: OOM (HighMem) on linux 2.6.24.2, Kevin Shanahan, (Thu Mar 20, 3:17 am)
Re: OOM (HighMem) on linux 2.6.24.2, Denys Vlasenko, (Mon Mar 31, 7:31 pm)
Re: OOM (HighMem) on linux 2.6.24.2, Peter Zijlstra, (Mon Mar 31, 9:57 pm)
Re: OOM (HighMem) on linux 2.6.24.2, Denys Vlasenko, (Tue Apr 1, 1:17 am)
Re: OOM (HighMem) on linux 2.6.24.2, KOSAKI Motohiro, (Tue Apr 1, 1:38 am)