Sparsh Mittal:

I am allocating 2d array as:

double[gridSize][gridSize] gridInfo;

which works for small dimension, but for large dimension, 16Mb limit comes.

Walter has decided to introduce a very low limit for the size of static arrays. (Both Clang and G++ support larger ones).


Would you please tell me how do allocate a large 2d array (which has to be done as a dynamic array)? It is a square grid and dimensions are already known.

This allocates your array, filled with NaNs:

auto gridInfo = new double[][](gridSize, gridSize);


If you want to skip most or all the initialization then take a look at two functions in std.array. In most cases the "partially initialized" function is enough, and it's quite safer.

Bye,
bearophile

Reply via email to