Fix out-of-bound index and clean up code.
There was an out-of-bound index after something like 7.5 hours of
active use. This probably caused the metrics daemon to restart
and pollute some of the memuse statistics, the very ones
responsible for the overflow.
BUG=chromium:326824
TEST=ran manually and verified memuse is still reported
Change-Id: I70709f8cbba63ea1ca5e277b2ab58729e072e127
Reviewed-on: https://chromium-review.googlesource.com/178976
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
diff --git a/metrics/metrics_daemon.h b/metrics/metrics_daemon.h
index d3a4f72..82372f8 100644
--- a/metrics/metrics_daemon.h
+++ b/metrics/metrics_daemon.h
@@ -329,12 +329,8 @@
bool FillMeminfo(const std::string& meminfo_raw,
std::vector<MeminfoRecord>* fields);
- // Schedule a memory use callback. |new_callback| is true when this callback
- // is scheduled for the first time. When |new_callback| is false,
- // |time_elapsed| is the active (non-sleep) time that has passed between now
- // and the original callback scheduling time. We use it to reschedule a
- // callback that fired too early because we slept.
- void ScheduleMemuseCallback(bool new_callback, double time_elapsed);
+ // Schedule a memory use callback in |interval| seconds.
+ void ScheduleMemuseCallback(double interval);
// Static wrapper for MemuseCallback. Always returns false.
static gboolean MemuseCallbackStatic(void* handle);
@@ -405,8 +401,8 @@
// Scheduled daily use monitor source (see ScheduleUseMonitor).
GSource* usemon_source_;
- // Time of initial scheduling of memuse callback
- double memuse_initial_time_;
+ // End time of current memuse stat collection interval.
+ double memuse_final_time_;
// Selects the wait time for the next memory use callback.
unsigned int memuse_interval_index_;