In my code is necessary to allocate several large arrays.
However, when I try to use the IBM xlc_r :
xlc_r -g -O -L. -qarch=pwr7 -qtune=pwr7 -lesslsmp -lm -qsmp -qthreaded -qmaxmem=-1 2.c
int main()
{
int natom = 5000;
while(1)
{
double *z =(double*) malloc(natom*natom*natom* sizeof(double));
if(!z)
{
printf("error memory vector z\n\n");
exit(-1);
}
}
}
I receive either Killed an error for memory vector z.
This is the ulimit -a
:
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 102400
pipe size (512 bytes, -p) 64
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 128
virtual memory (kbytes, -v) unlimited
Is there any flag necessary to allocate more memory?
I hit this issue on a POWER775 AIX machine a while back. You need to add the
-q64
flag when compiling in order to allocate more than 2GiB of memory. Note that the comments by others about usingint
may be relevant to your code, which is why my example below usessize_t
.I recommend you run a simple test of allocation to investigate this. My tester that I wrote for this situation is below.
The associated build flags were as follows.