I have a problem with the creation of a too big matrix with slurm cluster(Out of memory killed). How can I fix the problem? The following code is the part of the code about the allocation matrix:
double **matrix;
int rows = 30000;
int cols = 39996;
matrix = (double**)malloc(sizeof(double*)*rows);
for (int i = 0; i < rows; i++)
matrix[i] = (double*)malloc(sizeof(double)*cols);
for(int i=0; i<rows; i++)
for(int j=0; j<cols; j++)
matrix[i][j] = 1;
This value (rows, cols) are an example because I can also have larger value Instead the following code is the part of code about deallocation:
for (int i = 0; i < 30000; i++)
free(matrix[i]);
free(matrix);
This my output: Slurmstepd: error: Detected 1 oom-kill event(s) in step 98584.0 cgroup. Some of your processes may have been killed by the cgroup out-of-memory handler. srun: error: lab13p1: task 1: Out Of Memory