1
在我的代码需要分配几个大阵,但是当我尝试使用IBM xlc_r:xlc_r -g -O -L. -qarch=pwr7 -qtune=pwr7 -lesslsmp -lm -qsmp -qthreaded -qmaxmem=-1 2.c
内存alocation IBM AIX
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);
}
}
}
有时候,我收到杀,有时:错误记忆向量z
这是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
有没有必要分配更多内存的标志?
你确实意识到你正在分配500千兆字节吗?我很确定你的电脑没有那么多的内存。 –
@MooingDuck我认为一个TB,假设ieee754双(64位)。但另一个问题是'natom * natom * natom'会导致整数溢出,除非'int'也是64位 –
“Killed”错误可能表示操作系统使用延迟分配 –