diff options
author | Martin Leitner-Ankerl <martin.ankerl@gmail.com> | 2022-06-11 11:00:53 +0200 |
---|---|---|
committer | Martin Leitner-Ankerl <martin.ankerl@gmail.com> | 2023-03-23 19:38:38 +0100 |
commit | 5e4ac5abf54f8e6d6330df0c73119aa0cca4c103 (patch) | |
tree | 5a5310f5fdf6302a89ee35127e6cf4c9b02b1b8a /src/coins.cpp | |
parent | 1afca6b663bb54022afff193fd9d83856606b189 (diff) | |
download | bitcoin-5e4ac5abf54f8e6d6330df0c73119aa0cca4c103.tar.xz |
Call ReallocateCache() on each Flush()
This frees up all associated memory with the map, not only the nodes.
This is necessary in preparation for using the PoolAllocator for
CCoinsMap, which does not actually free any memory on clear().
Diffstat (limited to 'src/coins.cpp')
-rw-r--r-- | src/coins.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/coins.cpp b/src/coins.cpp index 5a6ae525a7..f55932f302 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -253,9 +253,12 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn bool CCoinsViewCache::Flush() { bool fOk = base->BatchWrite(cacheCoins, hashBlock, /*erase=*/true); - if (fOk && !cacheCoins.empty()) { - /* BatchWrite must erase all cacheCoins elements when erase=true. */ - throw std::logic_error("Not all cached coins were erased"); + if (fOk) { + if (!cacheCoins.empty()) { + /* BatchWrite must erase all cacheCoins elements when erase=true. */ + throw std::logic_error("Not all cached coins were erased"); + } + ReallocateCache(); } cachedCoinsUsage = 0; return fOk; |