mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Fix Memory Exhaustion on Mass Import/Sync
.. RideCache::addRide() deletes the prior ride, which is rather meaningless if you are just importing a ride, but when syncing large numbers of rides will stop memory being exhausted. .. similarly in the FileStoreSyncDialog we now free up the memory used to read the downloaded files before moving on to the next.
This commit is contained in:
@@ -1098,7 +1098,7 @@ FileStoreSyncDialog::downloadNext()
|
||||
rideListDown->setCurrentItem(curr);
|
||||
progressLabel->setText(QString(tr("Downloaded %1 of %2")).arg(downloadcounter).arg(downloadtotal));
|
||||
|
||||
QByteArray *data = new QByteArray;
|
||||
QByteArray *data = new QByteArray; // gets deleted when read completes
|
||||
store->readFile(data, curr->text(1));
|
||||
QApplication::processEvents();
|
||||
return true;
|
||||
@@ -1145,7 +1145,8 @@ FileStoreSyncDialog::completedRead(QByteArray *data, QString name, QString messa
|
||||
// uncompress and parse
|
||||
QStringList errors;
|
||||
RideFile *ride = store->uncompressRide(data, name, errors);
|
||||
|
||||
|
||||
// was allocated in before calling readfile
|
||||
delete data;
|
||||
|
||||
progressBar->setValue(++downloadcounter);
|
||||
@@ -1158,6 +1159,9 @@ FileStoreSyncDialog::completedRead(QByteArray *data, QString name, QString messa
|
||||
} else {
|
||||
curr->setText(col, errors.join(" "));
|
||||
}
|
||||
|
||||
// delete once saved
|
||||
delete ride;
|
||||
} else {
|
||||
curr->setText(col, errors.join(" "));
|
||||
}
|
||||
|
||||
@@ -164,6 +164,8 @@ RideCache::itemChanged()
|
||||
void
|
||||
RideCache::addRide(QString name, bool dosignal, bool useTempActivities)
|
||||
{
|
||||
RideItem *prior = context->ride;
|
||||
|
||||
// ignore malformed names
|
||||
QDateTime dt;
|
||||
if (!RideFile::parseRideFileName(name, &dt)) return;
|
||||
@@ -201,6 +203,11 @@ RideCache::addRide(QString name, bool dosignal, bool useTempActivities)
|
||||
|
||||
if (dosignal) context->notifyRideAdded(last); // here so emitted BEFORE rideSelected is emitted!
|
||||
|
||||
// free up memory from last one, which is no biggie when importing
|
||||
// a single ride, but means we don't exhaust memory when we import
|
||||
// hundreds/thousands of rides in a batch import.
|
||||
if (prior) prior->close();
|
||||
|
||||
// notify everyone to select it
|
||||
context->ride = last;
|
||||
context->notifyRideSelected(last);
|
||||
|
||||
@@ -401,12 +401,23 @@ RideItem::isOpen()
|
||||
void
|
||||
RideItem::close()
|
||||
{
|
||||
// ride data
|
||||
if (ride_) {
|
||||
// break link to ride file
|
||||
foreach(IntervalItem *x, intervals()) x->rideInterval = NULL;
|
||||
delete ride_;
|
||||
ride_ = NULL;
|
||||
}
|
||||
|
||||
// and the cpx data
|
||||
if (fileCache_) {
|
||||
delete fileCache_;
|
||||
fileCache_=NULL;
|
||||
}
|
||||
|
||||
// and the intervals
|
||||
foreach(IntervalItem*x, intervals_) delete x;
|
||||
intervals_.clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user