What are the possible cases that can make the following code to execute the if
condition in the following snippet? As far as I'm concerned, I can't relate any cause for the if
statement to execute.
#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);}
I'm working with a FEM code that has this check in the middle of a very large program. The interesting fact is when I run the code, it shows anomalous behavior. Sometimes the program stops just here. Sometimes it just works fine. One thing that is worthy to be mentioned that is when the program is run with coarse mesh i.e. when Nod
has less number of nodes to calculate, the program just works fine. But when a fine mesh is used, the program crashes unfortunately. This program is run in a mini workstation which have 128GB Ram. The program occupies 1GB (or so) of RAM.