mprotect() failed: Cannot allocate memory

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: =?utf-8?q?Pawe=C5=82_Sikora?=
Date: Tuesday, April 20, 2010 - 4:05 pm

hi,

i'm trying to debug an ugly application with ElectricFence.
in fact, on x86-64 box with 8GB ram and 16GB swap i'm getting following error:

"ElectricFence Exiting: mprotect() failed: Cannot allocate memory"

the program has been compiled with gcc-4.5, glibc-2.11.1, kernel-2.6.32.
did you ever come across such (kernel/glibc) limitations?

here's a simple testcase which triggs -ENOMEM in mprotect().

#define N 100
#include<stdlib.h>

double **bm;
int main(){
    int i;
    long NN = 4*N*N;
    int kmax=100;

        bm = (double **)malloc((time_t)NN*sizeof(double *));
        for(i=0; i<NN; ++i){
                bm[i] = (double*)malloc((time_t)kmax*sizeof(double));
        }

        for(i=0; i<NN; ++i){
                free(bm[i]);
        }
        free(bm);
        return 0;
}

thanks for any hint,

BR,
Pawel.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
mprotect() failed: Cannot allocate memory, =?utf-8?q?Pawe=C5=82 ..., (Tue Apr 20, 4:05 pm)
Re: mprotect() failed: Cannot allocate memory, Paweł Sikora, (Wed Apr 21, 2:42 am)
Re: mprotect() failed: Cannot allocate memory, Peter Zijlstra, (Wed Apr 21, 3:16 am)