Add 'dropCache' function to remove extraneous nodes from memory.

This commit is contained in:
JoelKatz
2013-01-27 13:55:06 -08:00
parent 43cc001eb9
commit bdd5d4af9f
3 changed files with 19 additions and 0 deletions

View File

@@ -153,6 +153,13 @@ public:
// low level functions
SHAMap::ref peekTransactionMap() { return mTransactionMap; }
SHAMap::ref peekAccountStateMap() { return mAccountStateMap; }
void dropCache()
{
if (mTransactionMap)
mTransactionMap->dropCache();
if (mAccountStateMap)
mAccountStateMap->dropCache();
}
// ledger sync functions
void setAcquiring(void);

View File

@@ -851,6 +851,15 @@ bool SHAMap::getPath(const uint256& index, std::vector< std::vector<unsigned cha
return true;
}
void SHAMap::dropCache()
{ // CAUTION: Changes can be lost
boost::recursive_mutex::scoped_lock sl(mLock);
mTNByID.clear();
if (root)
mTNByID[*root] = root;
}
void SHAMap::dump(bool hash)
{
#if 0

View File

@@ -382,6 +382,9 @@ public:
// Returns a new map that's a snapshot of this one. Force CoW
SHAMap::pointer snapShot(bool isMutable);
// Remove nodes from memory
void dropCache();
// hold the map stable across operations
ScopedLock Lock() const { return ScopedLock(mLock); }