Skip to content

Commit

Permalink
1658 Fix totalMemory calculation used for garbage collection
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Sep 20, 2023
1 parent 98f342d commit 8a5d3a4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libethereum/BlockChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,8 @@ void BlockChain::garbageCollect( bool _force ) {

m_lastCollection = chrono::system_clock::now();

while ( m_lastStats.memTotal() >= c_maxCacheSize ) {
// We subtract memory that blockhashes occupy because it is treated sepaparately
while ( m_lastStats.memTotal() - m_lastStats.memBlockHashes >= c_maxCacheSize ) {
Guard l( x_cacheUsage );
for ( CacheID const& id : m_cacheUsage.back() ) {
m_inUse.erase( id );
Expand Down Expand Up @@ -1316,6 +1317,7 @@ void BlockChain::garbageCollect( bool _force ) {

{
WriteGuard l( x_blockHashes );
// This is where block hash memory cleanup is treated
// allow only 4096 blockhashes in the cache
if ( m_blockHashes.size() > 4096 ) {
auto last = m_blockHashes.begin();
Expand Down

0 comments on commit 8a5d3a4

Please sign in to comment.