16

I have a Raspberry Pi with 925 MB of memory. Bitcoin Core, operating as a full node, uses between 600-900 MB. How can I reduce bitcoind's memory usage?

I tried setting maxmempool to its minimum allowed value, 5. What about maxreceivebuffer and maxsendbuffer? Would setting these to a low value reduce memory usage?

Michael Folkson
  • 14,337
  • 3
  • 11
  • 45
Geremia
  • 4,469
  • 4
  • 37
  • 75
  • 2
    Short comment before writing a full answer: a 5 MB mempool isn't particularly useful. You might as well disable the mempool entirely with `-blocksonly`. – Pieter Wuille Jan 06 '17 at 00:26
  • @PieterWuille That's a good suggestion. I didn't know about that option. It probably lowers memory usage, too. In fact, [this Reddit post on running a node on a 512 MB Raspberry Pi](https://www.reddit.com/r/Bitcoin/comments/5ffwg2/raspberry_pi_1_b_512mb_ram_running_bitcoind_0131/) mentions using that flag, too. – Geremia Jan 06 '17 at 00:50
  • With -blocksonly you don't have any mempool at all. – Pieter Wuille Jan 10 '17 at 02:10

2 Answers2

20

The largest consumers of memory are:

  • The memory pool (reduce with -maxmempool, or disable entirely with -blocksonly if you don't care about unconfirmed transactions).
  • The UTXO cache (reduce with -dbcache, at the cost of potentially much slower syncing).
  • The signature cache (reduce with -maxsigcachesize).

In addition, you can also reduce the maximum number of connections (-maxconnections) or the number of RPC threads (-rpcthreads).

A viable minimum configuration without mempool could be -blocksonly -dbcache=20 -maxsigcachesize=4 -maxconnections=4 -rpcthreads=1.

Some advice is also included in the documentation under https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md

Pieter Wuille
  • 98,249
  • 9
  • 183
  • 287
  • `-blocksonly` alone brought my node's memory footprint down to about ~700 MB. I also have `-banscore` set to 1, which seems to help get rid of spammy nodes that flood my node with bad transactions. – Geremia Jan 12 '17 at 15:04
  • Was still crashing with me! But setting also `maxmempool=100` was causing bitcoind to be at ca. 570MB RSS, that works on my 1GB VPS. – Borph Mar 20 '17 at 08:48
  • 2
    I used the follow options: blocksonly=1 dbcache=50 maxorphantx=10 maxmempool=100 maxconnections=32 and bitcoind is running smoothly on my raspberrypi with the follow Memory footprint VSZ 422524 and RSZ 266956 – Zioalex Sep 04 '17 at 19:39
  • carefully set blocksonly=1,in my case when i set this parameter,the txid cant be added to mempool and stucked for a very long time.no errors in log. – nervalpoet May 13 '22 at 02:15
  • Some more details available at: https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md – Riccardo Casatta Jun 03 '22 at 15:26
5

Followed your parameter:

bitcoind -blocksonly=1 -dbcache=50 -maxorphantx=10 -maxmempool=100 & 

Now I have only 286M memory used with bitcoind running.

bomben
  • 498
  • 2
  • 4
  • 11
Makarthur
  • 51
  • 1
  • 2
  • 1
    Please don't use the "answer" box to write "thank you" type comments. Please take the [tour] and check [this faq on deleted answers](https://bitcoin.stackexchange.com/help/deleted-answers). – Hannah Vernon Sep 21 '18 at 19:29
  • 1
    In my opinion this answer does add a bit more new information so I don't think it needs to be deleted – meshcollider Sep 23 '18 at 12:55
  • 3
    Why are you setting `-maxmemool` if you already have `-blocksonly`? Seems redundant to me but I might be missing something. – Gunar Gessner Jan 31 '21 at 18:39