0

I have narrowed it down to the specific line of which is causing the segmentation fault.

int match[2000][2][2000];

Am I exceeding my computers memory limits with this array because my code works flawlessly when changed to this.

int match[1000][2][1000];
jibidabo
  • 33
  • 1
  • 3
  • 8
    You are exceeding the stack size yes. Use std::vector – Borgleader May 22 '15 at 19:59
  • 1
    The easier solution is to not put this on the stack. Create a `struct` and allocate that using `new`. The stack should be for fairly small allocations, on the order of hundreds of bytes, not something gigantic like this. – tadman May 22 '15 at 20:02

1 Answers1

4

It seems that you're effectively exceeding the stack limit.

You can check it via ulimit -s or ulimit -a to check all limits currently set.

Simply use ulimit -s <your size> to increase the stack size or use dynamic memory allocation (but I guess you're already aware of this solution).

PS: ulimit is to be ran in a shell.

cfz42
  • 384
  • 1
  • 14