I'm under Windows (10, I guess), using Msys2 for development. I'm coding a program where I need a large array, but I can't use dynamic memory. The problem is, this array is too large to fit on the callstack, which produces a stackoverflow.
I tried to change the callstack size with ulimit -s 100000
. But my program still crash. When I check with the same command ulimit -s
I've got the limit I set. But when I check with a small program with getrlimit
, I've got the default value.
I saw in this thread that we can change some of the Msys2 config values with the file msys.bat
, but i can't find this file.
My Question
How can I change the callstack on windows/Msys2?
Pass the large array by pointer
#include <stdio.h>
char large_array[100000000];
void myfunc (char *array, size_t size)
{
for (int i=0; i<size; i++)
//STUFF
}
int main()
{
myfunc(large_array, sizeof(large_array)/sizeof(large_array[0]));
return 0;
}