I'm wondering why this works up to a size of 1e8. For sizes larger than 1e8, the compiler says "size too large".
#include <stdio.h>
int main() {
printf("allocating...\n");
static float m[(int)1e8];
printf("done\n");
}
While this works only up to 1e5. If size is set to 1e6, it does compile fine, but crashes in runtime even before the first line is printed.
#include <stdio.h>
int main() {
printf("allocating...\n");
float m[(int)1e5];
printf("done\n");
}
What are these limits? And why the static has a higher limit?
edit: platform is MinGW64 in windows7. Haven't tested it in linux yet.
ulimit -sto determine the maximum allowed stack size. This is typically 8 MB. (It is printed in multiples of 1 kB).