I am coming up against a segmentation fault in my code that I can only explain through insufficient available memory. What is happening is that I am trying to create a NxN
matrix where N
is a large number. For N=8
, the programme runs fine, but for N>=16³=5000
, I get a segmentation fault automatically. This is ew Is there any simple way of solving this problem? I actually want to simulate sizes of the range N=64³
if possible, so this is a very essential question for me.
My code structure is as follows.
const int N=16**3;
int main(int argc, const char * argv[]) {
double rnorm[N][N];
...
}
void Diluisci(..., double rnorm[N][N]{
...
AdjMatOnestep(rnorm);
}
void AdjMatOnestep(double rnorm[][N]){
...}
So main()
calls Diluisci()
which calls AdjMatOnestep()
, and as soon as I call this last function, I get a segmentation fault. I don't even enter into the first line of it. DDD says "error reading variable: Cannot access memory at address ...".
Any ideas?