0

A program includes two large arrays on a function (main):

int array [1000][1000];
char anotherArray [1000][1000];

On Linux, it seems to work perfectly fine but on Windows the program crashes unless these arrays are moved to global scope.

It seems to be an OS-specific issue, what causes it?

Edit: this question is about the differences between both OSs

Answer

(as the question has been marked as duplicate, I can't answer it directly)

The reason is that the stack is used for local variables (as explained on the other answers on Stack Overflow); on Windows its size is 1 MB but on Linux it's 8 MB by default, so there's more space available.

simplegamer
  • 212
  • 2
  • 10
  • The stack size is os-specific and small compared to the size available for global variables and dynamically allocated memory. – R Sahu Mar 26 '19 at 04:21
  • It would be better if you posted your *answer* section to the other question, saying that the number is different and that for example "this crashes on Windows" when "only this is sufficient on Linux kernel yadayada" – Antti Haapala -- Слава Україні Mar 26 '19 at 06:31

0 Answers0