In C++, how much more do dynamic multi-dimensional arrays use?
Posted on 2014-03-06
In looking at the available Physical Memory in Task Manager while my program is executing in the debugger, I've realized that the dynamically allocated multi-dimensional arrays in my VS2012 C++ application use A LOT MORE MEMORY than I would expect.
Let's assume for this discussion that my computer needs 8 bytes to store a variable of data type "double". Well, I would've expected that the amount of memory (ie, the heap) needed for a two-dimensional array of size  (using the "new" keyword) would simply be 1000 * 50 * 8 bytes = 400,000 bytes (ie, 400 K). Well, I must be misunderstanding the algorithm, because more than twice this much memory is actually be "taken" from the supply of available memory.
So, if someone can explain the algorithm for the use of dynamically allocated memory with regard to arrays, and in particular multi-dimensional arrays, I would greatly appreciate it.