64,648
社区成员
发帖
与我相关
我的任务
分享
//类定义
class t_satObs {
public:
t_satObs() {}
t_satObs(const t_satObs& old) { // copy constructor (deep copy)
_staID = old._staID;
_prn = old._prn;
_time = old._time;
for (unsigned ii = 0; ii < old._obs.size(); ii++) {
_obs.push_back(new t_frqObs(*old._obs[ii]));
}
}
~t_satObs() {for (unsigned ii = 0; ii < _obs.size(); ii++) delete _obs[ii];}
std::string _staID;
t_prn _prn;
bncTime _time;
std::vector<t_frqObs*> _obs;
};
//出现问题的循环,如果加上这段代码,内存总是一直增加,可是没有发现什么问题呀!
while(true)
{
if (_rnx)
{
long iSec = long(floor(obs._time.gpssec()+0.5));
if (_rnx->samplingRate() == 0 || iSec % _rnx->samplingRate() == 0)
{
_rnx->deepCopy(obs);
}
_rnx->dumpEpoch(format, obs._time);
}
}
//调用的函数
void deepCopy(t_satObs obs) {
_obs.push_back(obs); //_obs为_rnx成员变量,定义:QList<t_satObs> _obs;
}
void dumpEpoch(const QByteArray& format, const bncTime& maxTime) {
QList<t_satObs> obsList;
QMutableListIterator<t_satObs> mIt(_obs);
while (mIt.hasNext()) {
t_satObs obs = mIt.next();
if (obs._time < maxTime) {
obsList.push_back(obs);
mIt.remove();
}
}
}