ostringstream memory increase

When the function "rinexSatLine" is running ,the memory is always increasing。Finally, the error "std::bad_alloc" occurs.
I cannot find the reason, Hope for a solution. Thanks very much.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
rinexSatLine(const t_obs& obs, char lli1, char lli2, 
                              char lli5) {
  ostringstream str;
  str.setf(ios::showpoint | ios::fixed);

  if (_header._version >= 3.0) {
    str << obs.satSys 
        << setw(2) << setfill('0') << obs.satNum << setfill(' ');
  }

  const QVector<QString>& types = (_header._version > 3.0) ?
                          _header._obsTypesV3[obs.satSys] : _header._obsTypesV2;
  for (int ii = 0; ii < types.size(); ii++) {
    if (_header._version < 3.0 && ii > 0 && ii % 5 == 0) {
      str << endl;
    }
    double value = obs.measdata(types[ii], _header._version);
    str << setw(14) << setprecision(3) << value;
    if      (value != 0.0 && types[ii].indexOf("L1") == 0) {
      str << lli1 << ' ';
    }
    else if (value != 0.0 && types[ii].indexOf("L2") == 0) {
      str << lli2 << ' ';
    }
    else if (value != 0.0 && types[ii].indexOf("L5") == 0) {
      str << lli5 << ' ';
    }
    else {
      str << "  ";
    }
  }

  return str.str();
}
Last edited on
try to print out the size of the QVector, maybe that's accidently a huge number.
Topic archived. No new replies allowed.