Pre-allocated vector of vectors yet still linear increase of memory while
filling it
I am confused why the system monitor is showing me that my memory is
increasing linearly, as I read in every line (into the same variable),
while storing a split of the string in pre-allocated memory.
// pre-allocate
int rows = 100000;
int columns = 300;
QVector<QString> matrix_row;
matrix_row.resize(rows);
QVector< QVector<QString> > matrix;
matrix.resize(num_columns);
qFill(matrix.begin(), matrix.end(), matrix_row);
int current_row = 0;
while(!filestream.atEnd())
{
QString line = filestream.readLine();
for (int i = 0; i < num_columns; i++)
{
matrix[i][current_row] = line.left(end[i]).right(grom[i]);
}
++current_row;
}
Speed is a concern, so I am thinking perhaps something is wrong.
It starts at around 26% once the initial allocation, and it ends at around
65% of my 8gb of ram.
What could be wrong?
No comments:
Post a Comment