diff options
author | James O'Beirne <james.obeirne@gmail.com> | 2019-09-16 15:01:12 -0400 |
---|---|---|
committer | James O'Beirne <james.obeirne@pm.me> | 2020-07-01 14:44:28 -0400 |
commit | f36aaa6392fdbdac6891d92202d3efeff98754f4 (patch) | |
tree | 4cebab3fa566f6f9dc53228b92264f1cda6095b1 /src/init.cpp | |
parent | b223111da2e0e9ceccef75df8a20252b0094b7bc (diff) |
Add CChainState::ResizeCoinsCaches
Also adds CCoinsViewCache::ReallocateCache() to attempt to free
memory that the cacheCoins's allocator may be hanging onto when
downsizing the cache.
Adds `CChainState::m_coins{tip,db}_cache_size_bytes` data members
so that we can reference cache size on a per-chainstate basis for
flushing.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp index 37e6251295..4561a10870 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1533,7 +1533,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node) int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20); // cap total coins db cache nTotalCache -= nCoinDBCache; - nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache + int64_t nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; LogPrintf("Cache configuration:\n"); LogPrintf("* Using %.1f MiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024)); @@ -1645,7 +1645,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node) } // The on-disk coinsdb is now in a good state, create the cache - chainstate->InitCoinsCache(); + chainstate->InitCoinsCache(nCoinCacheUsage); assert(chainstate->CanFlushToDisk()); if (!is_coinsview_empty(chainstate)) { |