diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenutil/cache/rpcrecording.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/zenutil/cache/rpcrecording.cpp b/src/zenutil/cache/rpcrecording.cpp index ac74b95f6..93af1ff29 100644 --- a/src/zenutil/cache/rpcrecording.cpp +++ b/src/zenutil/cache/rpcrecording.cpp @@ -22,6 +22,18 @@ ZEN_THIRD_PARTY_INCLUDES_END #include <deque> #include <thread> +namespace zen { + +template<typename T> +void +ClearContainer(T& Container) +{ + T Empty; + swap(Container, Empty); +} + +} // namespace zen + namespace zen::cache { const RecordedRequestInfo RecordedRequestInfo::NullRequest = {.ContentType = ZenContentType::kUnknownContentType, @@ -483,8 +495,7 @@ RecordedRequestsSegmentWriter::EndWrite() // note that simply calling `.reset()` here will *not* release backing memory // and it's important that we do because on high traffic servers this will use // a lot of memory otherwise - std::vector<RecordedRequest> EmptyEntries; - swap(m_Entries, EmptyEntries); + ClearContainer(m_Entries); } void @@ -617,7 +628,10 @@ RecordedRequestsSegmentReader::BeginRead(const std::filesystem::path& BasePath, void RecordedRequestsSegmentReader::EndRead() { - m_BlockFiles.clear(); + // Ensure memory is released fully once we're done + + ClearContainer(m_BlockFiles); + ClearContainer(m_Entries); } RecordedRequestInfo |