This is possibly due to the stack size limit in the system. See ulimit -s
which in most systems of 8MB.
So, 1446 * 1446 * 4
is nearly 8MB
since enum takes size of int. So, you are not able to allocate more than the allowed stack size. The actual needed memory is 32768 * 32768 * 4
is nearly 4GB. You can probably use a bitmap
, since you are dealing with boolean
which reduces the needed memory. First changing the int
to char
reduces to 4GB / 4 = 1GB
and from char
to bit field reduces to 1GB / 8 = 128MB
Prefer using malloc
or calloc
for larger chunks of memory.