1

I know I can set -dbcache=<MB> when starting bitcoind.
Does this effect how much RAM is allocated for the UTXOPool or UTXOPool + mempool?
How can I know how much RAM does each database take in RAM?

If the UTXO pool is 2.7GB, and I set -dbcache=4096, what happens to the rest of the alloated memory?

2

In Bitcoin Core, there are two settings, -dbcache and -maxmempool, defaulting to 450 and 300, respectively.

The mempool can only occupy as much as is configured through -maxmempool.

The UTXO set cache can occupy as much as is configured through -dbcache plus the amount of configured mempool space that is currently unused. The memory usage is however much higher than the equivalent representation on disk - loading the entire UTXO set would require 6-7 GiB at the time of speaking.

The in-memory representations are always larger. On disk they're just packed sequences of bytes. In memory, there are indexes and pointers, and memory allocation overhead - all to speed up access. The blowup factor for UTXO data is larger than for memory.

Since 0.14, the mempool is also saved to disk at shutdown (but not continuously).

So far, there is no prioritization done on the UTXO cache. We just keep all accessed entries around, and when it grows too large, all the modified entries are written to disk. One (very) significant optimization is that when a UTXO is created and then spent, without being written to disk in between, we just remove it from memory.

  • Is the memory usage of the mempool same as the representation on disk? If not, is it logged somewhere? Could you please tell me why does the UTXO set take much more than the representation on disk? And is there a priority to which outputs are kept in RAM? – amanusk Oct 12 '17 at 17:34
  • I've updated the answer to address these questions. – Pieter Wuille Oct 12 '17 at 23:29
  • Thanks. So last question. If I use -dbcache=16384 will 16GB of my RAM be used regardless of the actual size the UTXO set will take up in RAM? – amanusk Oct 14 '17 at 17:19
  • No, only as much as can be used. – Pieter Wuille Oct 14 '17 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.