diff options
| author | Stefan Boberg <[email protected]> | 2025-06-11 16:12:03 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-06-11 16:12:03 +0200 |
| commit | 2548d75adbd2bacb5257024c84dafb6d7a7ae4d0 (patch) | |
| tree | f98eab916976411eb268c3cd91271c3fb901e800 /src | |
| parent | factored out IterateSegments() (diff) | |
| download | zen-2548d75adbd2bacb5257024c84dafb6d7a7ae4d0.tar.xz zen-2548d75adbd2bacb5257024c84dafb6d7a7ae4d0.zip | |
Added ClearContainer helper
Used to empty containers completely, since .clear() doesn't necessarily release the backing memory
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 |