Close previous logger first when restarting
The LZMA compressor is a massive memory user, and having both open at
once significantly increases peak memory usage, which is all that
matters since the OS doesn't reliably reclaim memory from the logger.
Digging in further, we have very few to no mallocs right now in a
lzma logger when it is up and running. The increasing memory
usage comes from the kernel paging memory in behind the heap when it
gets accessed the first time, and the high peak memory needed by
rotating.
If this isn't enough, we should be able to figure out how to make a pool
for the lzma compressor so it doesn't re-allocate.
Change-Id: Ife2d6a1d51b279aadd99825ce2018d608493d360
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/events/logging/log_writer.h b/aos/events/logging/log_writer.h
index 0063c9b..d127f1b 100644
--- a/aos/events/logging/log_writer.h
+++ b/aos/events/logging/log_writer.h
@@ -250,9 +250,12 @@
// Fetches from each channel until all the data is logged. This is dangerous
// because it lets you log for more than 1 period. All calls need to verify
// that t isn't greater than 1 period in the future.
- // Returns true if there is at least one message that has been fetched but
- // not yet written.
- bool LogUntil(monotonic_clock::time_point t);
+ //
+ // Returns true if there is at least one message written, and also returns the
+ // timestamp of the newest record that any fetcher is pointing to, or min_time
+ // if there are no messages published on any logged channels.
+ std::pair<bool, monotonic_clock::time_point> LogUntil(
+ monotonic_clock::time_point t);
void RecordFetchResult(aos::monotonic_clock::time_point start,
aos::monotonic_clock::time_point end, bool got_new,