Reduce the memory usage of the StopWatch during propagation
authorJocelyn Turcotte <jturcotte@woboq.com>
Fri, 17 Jun 2016 17:09:37 +0000 (19:09 +0200)
committerJocelyn Turcotte <jturcotte@woboq.com>
Fri, 17 Jun 2016 17:20:53 +0000 (19:20 +0200)
Use a QMap to avoid using a full hashtable for only a few entries, and
clear the QMap once we're done with the measuring. This saves a few
hundred bytes per job during propagation that would otherwise only be
freed at the end of the sync.

src/libsync/propagateupload.cpp
src/libsync/utility.h

index 795a2f2e92a06e31f5c85eed777207c730720217..f60106244aa54f7e4cece4df7f6caffea23188cd 100644 (file)
@@ -779,6 +779,8 @@ void PropagateUploadFileQNAM::slotPutFinished()
              << _stopWatch.durationOfLap(QLatin1String("ContentChecksum"))
              << _stopWatch.durationOfLap(QLatin1String("TransmissionChecksum"))
              << _item->_requestDuration;
+    // The job might stay alive for the whole sync, release this tiny bit of memory.
+    _stopWatch.reset();
 
     finalize(*_item);
 }
index 044988fe16c73328ab9667bdcaa461596ca25296..6dd2f1788ced9b7589dc7199025cda52133d64b0 100644 (file)
@@ -20,7 +20,7 @@
 #include <QByteArray>
 #include <QDateTime>
 #include <QElapsedTimer>
-#include <QHash>
+#include <QMap>
 
 namespace OCC {
 
@@ -121,7 +121,7 @@ namespace Utility
 
     class OWNCLOUDSYNC_EXPORT StopWatch {
     private:
-        QHash<QString, quint64> _lapTimes;
+        QMap<QString, quint64> _lapTimes;
         QDateTime _startTime;
         QElapsedTimer _timer;
     public: