Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1# Reduce Memory3There are a few parameters that can be dialed down to reduce the memory usage of `bitcoind`. This can be useful on embedded systems or small VPSes.5## Swapping7When the operating system is under memory pressure, it may swap memory pages from RAM to disk.8If this becomes continuous ("thrashing"), `bitcoind` can slow to a crawl, especially during initial sync or reindex.10If you see sustained swap I/O while `bitcoind` runs, restart with a lower `-dbcache`.11If needed, also reduce `-maxmempool`, `-maxconnections`, or use `-blocksonly`.12Bitcoin Core may warn at startup when `-dbcache` looks too large for the detected system memory.14## In-memory caches16The size of some in-memory caches can be reduced. As caches trade off memory usage for performance, reducing these will usually have a negative effect on performance.18- `-dbcache=<n>` - the UTXO database cache size, this defaults to `1024` (or `450` if less than `4096` MiB system RAM is detected). The unit is MiB (1024).19- The minimum value for `-dbcache` is 4.20- A lower `-dbcache` makes initial sync time much longer. After the initial sync, the effect is less pronounced for most use-cases, unless fast validation of blocks is important, such as for mining.22## Memory pool24- In Bitcoin Core there is a memory pool limiter which can be configured with `-maxmempool=<n>`, where `<n>` is the size in MB (1000). The default value is `300`.25- The minimum value for `-maxmempool` is 5.26- A lower maximum mempool size means that transactions will be evicted sooner. This will affect any uses of `bitcoind` that process unconfirmed transactions.28- The unused memory allocated to the mempool (default: 300MB) is shared with the UTXO cache, so when trying to reduce memory usage you should limit the mempool, with the `-maxmempool` command line argument.30- To disable most of the mempool functionality there is the `-blocksonly` option. This will reduce the default memory usage to 5MB and make the client opt out of receiving (and thus relaying) transactions, except from peers who have the `relay` permission set (e.g. whitelisted peers), and as part of blocks.32- Do not use this when using the client to broadcast transactions as any transaction sent will stick out like a sore thumb, affecting privacy. When used with the wallet it should be combined with `-walletbroadcast=0` and `-spendzeroconfchange=0`. Another mechanism for broadcasting outgoing transactions (if any) should be used.34## Number of peers36- `-maxconnections=<n>` - the maximum number of connections, which defaults to 200. Each active connection takes up some37memory. This option applies only if inbound connections are enabled; otherwise, the number of connections will not38be more than 11. Of the 11 outbound peers, there can be 8 full-relay connections, 2 block-relay-only ones,39and occasionally 1 short-lived feeler or extra outbound block-relay-only connection.41- These limits do not apply to connections added manually with the `-addnode` configuration option or42the `addnode` RPC, which have a separate limit of 8 connections.44## Thread configuration46For each thread a thread stack needs to be allocated. By default on Linux,47threads take up 8MiB for the thread stack on a 64-bit system, and 4MiB in a4832-bit system.50- `-par=<n>` - the number of script verification threads, defaults to the number of cores in the system minus one.51- `-rpcthreads=<n>` - the number of threads used for processing RPC requests, defaults to `16`.52- `-prevoutfetchthreads=<n>` - the number of threads used to fetch block input prevouts, defaults to `8`.54## Linux specific56By default, glibc's implementation of `malloc` may use more than one arena. This is known to cause excessive memory usage in some scenarios. To avoid this, make a script that sets `MALLOC_ARENA_MAX` before starting bitcoind:58```bash59#!/usr/bin/env bash60export MALLOC_ARENA_MAX=161bitcoind62```64The behavior was introduced to increase CPU locality of allocated memory and performance with concurrent allocation, so this setting could in theory reduce performance. However, in Bitcoin Core very little parallel allocation happens, so the impact is expected to be small or absent.
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.