<p>In Bitcoin Core, there are two settings, <code>-dbcache</code> and <code>-maxmempool</code>, defaulting to 450 and 300, respectively.</p>

<p>The mempool can only occupy as much as is configured through <code>-maxmempool</code>.</p>

<p>The UTXO set cache can occupy as much as is configured through <code>-dbcache</code> <em>plus</em> 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.</p>

<p>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.</p>

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

<p>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.</p>

CC BY-SA 3.0
2017-10-14T17:19:12.997Z
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
CC BY-SA 3.0
2017-10-14T17:38:55.957Z
No, only as much as can be used.
Pieter Wuille
CC BY-SA 3.0
2017-10-12T17:21:58.333Z
2017-10-12T18:07:06.253Z
2017-10-12T18:07:06.253Z
Pieter Wuille
<p>I know I can set <code>-dbcache=&lt;MB&gt;</code> when starting bitcoind.<br />
Does this effect how much RAM is allocated for the UTXOPool or UTXOPool + mempool?<br />
How can I know how much RAM each database takes?</p>
<p>If the UTXO pool is 2.7GB, and I set <code>-dbcache=4096</code>, what happens to the rest of the allocated memory?</p>

<bitcoin-core><bitcoind><bitcoin-cli><mempool><memory>
How much memory (RAM) is used by the mempool and UTXO pool?
amanusk
# How much memory (RAM) is used by the mempool and UTXO pool?

(Asked by: username_0 on 2017-10-12)

I know I can set `-dbcache=` when starting bitcoind.  
Does this effect how much RAM is allocated for the UTXOPool or UTXOPool + mempool?  
How can I know how much RAM each database takes?

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

**Tags:** bitcoin-core, bitcoind, bitcoin-cli, mempool, memory


---

## 1 answers

### Answer by username_1 on 2017-10-12. Score: 4 | Accepted answer

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.

> **Comments:**
> **username_0**: 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?  
> **username_1**: No, only as much as can be used.  

---

