I think the additional memory usage is due to the initial capacity of the string (it is implementation dependent, see, for instance this page:
"std::string length and capacity"[
^]).
Please note, posted code has mistakes, it should be
int X_range=100000; int Y_range=10;string **matrix;
matrix = new string * [X_range];
for (int x=0;x<X_range;x++)
{
matrix[x]= new string[Y_range];
for (int y=0; y<Y_range; y++)
matrix[x][y]="ABCD";
}
How did you check matrix memory usage?
On my system (Win 8 64 bits, with VS 2012) the
capacity of the
string
s is
15
).