I am currently making a simple game using different tiles from an image file and placing them with a terrain generator. The terrain generator is based on the diamond square algorithm and I tested it in a smaller scale and it works just fine. However, in my game I want to generate a map made out of 513*513 tiles, which means that I need an int to store the tile values with and array of [513][513], and I also need a double with the same array for the generator.

Declaring the int works just fine, but when I declare the double the program crashes from a stack overflow. Is there any good way to get around this?

PS. Even though this is about a game I thought it would be better to put it in the c++ section since the problem is a generic c++ problem and has nothing to do with the game.

Also, here is the code for my map class (as you can see, I am using SDL):