有哪些可能的情况可以使以下代码执行if以下代码段中的条件?就我而言,我无法将任何原因if与执行语句联系起来.
#include <stdio.h>
#include <stdlib.h>
void main(void){
int Nod = 1024 * 8; //Nod contains the number of nodes
double *MM; //MM is a square matrix it can contain very large number of data 10^10
MM = calloc(8 * Nod * 8 * Nod, sizeof(double));
if (MM == NULL)exit(0);
//then MM will then be passed to some other functions say
eigenvalue(MM);}
Run Code Online (Sandbox Code Playgroud)
我正在使用一个FEM代码,它在一个非常大的程序中间进行了这项检查.有趣的是,当我运行代码时,它会显示异常行为.有时程序会在这里停止.有时它只是工作正常.值得一提的是,当程序以粗网格运行时,即当Nod计算节点数量较少时,程序运行正常.但是当使用精细网格时,程序崩溃不幸.该程序在具有128GB Ram的迷你工作站中运行.该程序占用1GB(左右)的RAM.
Unhandled exception at 0x00AA9379 in A.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00802000).
我正面临堆栈溢出错误.我正在使用VS15作为我的IDE.我试图为堆栈分配更多内存.为此,我使用Project >> Properties >> Linker >> System >> Stack allocation并为堆栈分配了4GB.但错误继续停chkstk.asm在此线上
99 sub eax, _PAGESIZE_ ; decrease by PAGESIZE.
但问题没有解决.我如何提前知道我需要多少堆栈大小?我已经为所有大变量使用了动态内存分配.但无法解决问题.这是一个可验证的例子......
这是我的代码:
#include <stdio.h>
void main(void)
{
FILE *fp1;
char datfile[132];
int nod[1024 * 1024];
int Enod[8 * 1024 * 1024];
double nodS[1024 * 1024], nodF[1024 * 1024];
}
Run Code Online (Sandbox Code Playgroud)