Why is 248×248 the maximum bi dimensional array size I can declare?

There are three places where you can allocate an array in C:

  • In the automatic memory (commonly referred to as “on the stack”)
  • In the dynamic memory (malloc/free), or
  • In the static memory (static keyword / global space).

Only the automatic memory has somewhat severe constraints on the amount of allocation (that is, in addition to the limits set by the operating system); dynamic and static allocations could potentially grab nearly as much space as is made available to your process by the operating system.

The simplest way to see if this is the case is to move the declaration outside your function. This would move your array to static memory. If crashes continue, they have nothing to do with the size of your array.

Leave a Comment