malloc对内存有限制么,请帮忙修改一个程序

diana_cherry diana_cherry 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如下程序,分配了12288次就执行不了,机器的内存有几十G,这是怎么回事


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ARTICLE_S 12782
#define WORD_S 17547
int num_of_ulong(unsigned long i);
void error_and_die(const char *msg) {
perror(msg);
exit(EXIT_FAILURE);
}
//unsigned long v[WORD_S][ARTICLE_S];

int main(void){
unsigned long word,article;
unsigned long part,position;
unsigned long t;
unsigned long i,j,k;

unsigned long *v[ARTICLE_S];
for(i=0lu;i<WORD_S;i++){
v[i]=(unsigned long *)malloc(ARTICLE_S*sizeof(unsigned long));
printf("succ\n");
}
/**
* ......
}*/
for(i=0lu;i<WORD_S;i++){
free(v[i]);
}
}
...全文
评论 20
收藏 已收藏
分享
返回顶部
diana_cherry
C语言 70,040 成员 243,237 内容