Encode flatbuffers directly into the encoder when logging
We were running out of memory when running for many hours. Initial
debugging looked like it was a heap fragmentation issue. Tracking the
allocated memory using the malloc hooks wasn't showing any growth of
memory. The heap was growing though.
Instead of allocating a FlatBufferBuilder/DetachedBuffer for each
message to be logged, we can instead have the BufferEncoder provide
memory to write to, and have it only alloate that buffer space once, and
allocate it to the maximum size that a writer might see.
Change-Id: I046bd2422aea368867b0c63cee7d04c6033fe724
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/events/logging/snappy_encoder_test.cc b/aos/events/logging/snappy_encoder_test.cc
index 3334602..7e61f3f 100644
--- a/aos/events/logging/snappy_encoder_test.cc
+++ b/aos/events/logging/snappy_encoder_test.cc
@@ -9,8 +9,8 @@
INSTANTIATE_TEST_SUITE_P(
Snappy, BufferEncoderTest,
- ::testing::Combine(::testing::Values([]() {
- return std::make_unique<SnappyEncoder>();
+ ::testing::Combine(::testing::Values([](size_t max_message_size) {
+ return std::make_unique<SnappyEncoder>(max_message_size);
}),
::testing::Values([](std::string_view filename) {
return std::make_unique<SnappyDecoder>(filename);