DEV Community

Discussion on: The truth about impostor syndrome

Collapse
 
codemouse92 profile image
Jason C. McDonald

No, it's just that a 1000x1000 integer array is really large.

Assuming the int is 4 bytes (which it usually is), then a 1000-element array would be 4 B * 1000 = 4000 B = 4 KB. That would probably be fine. However, you actually have an array of arrays, 1000 of them to be exact. So, you have 4 KB * 1000 = 4000 KB = 4 MB. That's a bit excessive for the stack to begin with.

I had actually forgotten to mention, however, the professor had actually declared TWO of those 1000x1000 arrays. So, 4 MB * 2 = 8 MB. That's quite a lot of data to be cramming into the stack at once, and it overflowed.