mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
txgraph: expose memory usage estimate function (feature)
This commit is contained in:
@@ -629,6 +629,8 @@ public:
|
||||
std::unique_ptr<BlockBuilder> GetBlockBuilder() noexcept final;
|
||||
std::pair<std::vector<Ref*>, FeePerWeight> GetWorstMainChunk() noexcept final;
|
||||
|
||||
size_t GetMainMemoryUsage() noexcept final;
|
||||
|
||||
void SanityCheck() const final;
|
||||
};
|
||||
|
||||
@@ -2980,6 +2982,21 @@ std::vector<TxGraph::Ref*> TxGraphImpl::Trim() noexcept
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t TxGraphImpl::GetMainMemoryUsage() noexcept
|
||||
{
|
||||
// Make sure splits/merges are applied, as memory usage may not be representative otherwise.
|
||||
SplitAll(/*up_to_level=*/0);
|
||||
ApplyDependencies(/*level=*/0);
|
||||
// Compute memory usage
|
||||
size_t usage = /* From clusters */
|
||||
m_main_clusterset.m_cluster_usage +
|
||||
/* From Entry objects. */
|
||||
sizeof(Entry) * m_main_clusterset.m_txcount +
|
||||
/* From the chunk index. */
|
||||
memusage::DynamicUsage(m_main_chunkindex);
|
||||
return usage;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TxGraph::Ref::~Ref()
|
||||
|
||||
Reference in New Issue
Block a user