diff options
| author | Stefan Boberg <[email protected]> | 2023-12-20 17:09:13 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-20 17:09:13 +0100 |
| commit | a9ff98e1c5900ce162710d137ff3a7a68f746aae (patch) | |
| tree | e2624f7f8a5ece0b9a7aed62e5c90658359c7c76 /src | |
| parent | separate RPC processing from HTTP processing (#626) (diff) | |
| download | zen-a9ff98e1c5900ce162710d137ff3a7a68f746aae.tar.xz zen-a9ff98e1c5900ce162710d137ff3a7a68f746aae.zip | |
release RPC recording memory early (#627)
previously the segment would call `clear()` on the `m_Entries` vector but this does not release the backing memory so we have to do the `swap` dance
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenutil/cache/rpcrecording.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/zenutil/cache/rpcrecording.cpp b/src/zenutil/cache/rpcrecording.cpp index b8f9d65ef..5e00e8852 100644 --- a/src/zenutil/cache/rpcrecording.cpp +++ b/src/zenutil/cache/rpcrecording.cpp @@ -425,7 +425,7 @@ RecordedRequestsSegmentWriter::EndWrite() CbObjectWriter Cbo; Cbo << "time_start" << m_StartTime << "time_end" << m_EndTime << "duration" << Duration; Cbo << "segment_index" << m_SegmentIndex; - Cbo << "entry_count" << m_Entries.size() << "entry_size" << sizeof(RecordedRequest); + Cbo << "entry_count" << m_RequestCount << "entry_size" << sizeof(RecordedRequest); Cbo << "block_size" << RecordedRequestBlockSize << "standalone_threshold" << StandaloneFileSizeThreshold; Cbo.BeginObject("system_info"); @@ -446,7 +446,12 @@ RecordedRequestsSegmentWriter::EndWrite() std::error_code Ec; IndexFile.WriteAll(IndexBuffer, Ec); IndexFile.Close(); - m_Entries.clear(); + + // 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); } uint64_t |