Skip to content

Commit 7228ce8

Browse files
committed
Compensate for memory peak at flush time
1 parent 8ac8041 commit 7228ce8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode, int n
20052005
nLastSetChain = nNow;
20062006
}
20072007
int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
2008-
int64_t cacheSize = pcoinsTip->DynamicMemoryUsage();
2008+
int64_t cacheSize = pcoinsTip->DynamicMemoryUsage() * 2; // Compensate for extra memory peak (x1.5-x1.9) at flush time.
20092009
int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0);
20102010
// The cache is large and we're within 10% and 100 MiB of the limit, but we have time now (not in the middle of a block processing).
20112011
bool fCacheLarge = mode == FLUSH_STATE_PERIODIC && cacheSize > std::max((9 * nTotalSpace) / 10, nTotalSpace - 100 * 1024 * 1024);

0 commit comments

Comments
 (0)