Do not use std::vector = {} to release memory

This commit is contained in:
Pieter Wuille
2023-09-11 13:54:32 -04:00
parent fd69ffbbfb
commit 3fcd7fc7ff
4 changed files with 57 additions and 14 deletions

View File

@@ -7,6 +7,7 @@
#include <pow.h>
#include <timedata.h>
#include <util/check.h>
#include <util/vector.h>
// The two constants below are computed using the simulation script on
// https://gist.github.com/sipa/016ae445c132cdf65a2791534dfb7ae1
@@ -51,9 +52,9 @@ HeadersSyncState::HeadersSyncState(NodeId id, const Consensus::Params& consensus
void HeadersSyncState::Finalize()
{
Assume(m_download_state != State::FINAL);
m_header_commitments = {};
ClearShrink(m_header_commitments);
m_last_header_received.SetNull();
m_redownloaded_headers = {};
ClearShrink(m_redownloaded_headers);
m_redownload_buffer_last_hash.SetNull();
m_redownload_buffer_first_prev_hash.SetNull();
m_process_all_remaining_headers = false;