Merge pull request #580 from ethcore/fixblockchainmem

shrink_to_fit after removing hashes.
This commit is contained in:
Gav Wood 2016-03-03 15:08:47 +01:00
commit 00b5fcebe3

View File

@ -448,7 +448,8 @@ impl BlockChain {
let mut write_details = self.block_details.write().unwrap();
for (hash, details) in update.block_details.into_iter() {
batch.put_extras(&hash, &details);
write_details.insert(hash, details);
write_details.insert(hash.clone(), details);
self.note_used(CacheID::Extras(ExtrasIndex::BlockDetails, hash));
}
let mut write_receipts = self.block_receipts.write().unwrap();
@ -759,6 +760,14 @@ impl BlockChain {
// TODO: handle block_hashes properly.
block_hashes.clear();
blocks.shrink_to_fit();
block_details.shrink_to_fit();
block_hashes.shrink_to_fit();
transaction_addresses.shrink_to_fit();
block_logs.shrink_to_fit();
blocks_blooms.shrink_to_fit();
block_receipts.shrink_to_fit();
}
if self.cache_size().total() < self.max_cache_size { break; }
}