Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75f0a4d3 authored by yro's avatar yro
Browse files

Use ProtoOutputStream's bytesWritten to properly estimate the size of

EventMetricsData on memory

Test: statsd, statsd_test
Change-Id: I6fc90c5d9303fe6cab582afb03c480969a6dc5a5
parent b3bd84d7
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ std::unique_ptr<std::vector<uint8_t>> EventMetricProducer::onDumpReport() {
    std::unique_ptr<std::vector<uint8_t>> buffer = serializeProto();

    startNewProtoOutputStream(endTime);
    mByteSize = 0;

    return buffer;
}
@@ -121,14 +120,10 @@ void EventMetricProducer::onMatchedLogEventInternal(
    event.ToProto(*mProto);
    mProto->end(eventToken);
    mProto->end(wrapperToken);

    // TODO: Increment mByteSize with a real value. Until this feature is working, we assume 50
    // bytes.
    mByteSize += 50;
}

size_t EventMetricProducer::byteSize() {
    return mByteSize;
    return mProto->bytesWritten();
}

}  // namespace statsd
+0 −2
Original line number Diff line number Diff line
@@ -65,8 +65,6 @@ protected:

private:
    const EventMetric mMetric;

    size_t mByteSize;
};

}  // namespace statsd