Memory leak with rest/block REST endpoint and getblock RPC when verbosity >=2 #30052

issue achow101 openend this issue on May 6, 2024
  1. achow101 commented at 5:53 pm on May 6, 2024: member

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    Reported in https://bitcointalk.org/index.php?topic=5495435.msg64037741#msg64037741

    When using either the rest/block endpoint or the getblock rpc with verbosity >=2, there appears to be a memory leak. Memory usage goes up ~100 MB for each call.

    The original reporter is repeatedly hitting the rest endpoint and eventually OOM’ing.

    Expected behaviour

    Memory should be freed after a response is sent, or be capped at some point to prevent an OOM.

    Steps to reproduce

    Observe bitcoind memory usage in top. Do getblock <blockhash> 2 and observe the memory usage increase. It fairly reliably reproduces, but does not always occur. Different blocks seem to have different effects, and repeating a block does not always increase usage.

    Relevant log output

    No response

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    v27.99.0-eb0bdbdd753b

    Operating system and version

    Arch

    Machine specifications

    No response

  2. maflcko commented at 6:14 am on May 7, 2024: member
    Is this a duplicate of #25229 (comment) ?
  3. maflcko commented at 6:16 am on May 7, 2024: member
    Related #24542 ?
  4. willcl-ark commented at 6:44 pm on May 7, 2024: member

    I could not reproduce an OOM, although I did observe resource usage increasing a little before eventually plateauing.

    I measured resident set size using python’s psutil module, whilst making 2500 REST requests for random blocks in the blockchain between block 0 and 842460. The node was in blocksonly mode, and had no peer connections.

    core-rest-5000

    I haven’t investigated any deeper than this yet.

  5. mzumsande commented at 9:52 pm on May 7, 2024: contributor

    I could not reproduce an OOM, although I did observe resource usage increasing a little before eventually plateauing.

    I see the same kind of behavior with Ubuntu with REST, the memory usage saturates after a few calls. So it looks like the same issue as in #25229 - at least for me.

  6. maflcko added the label RPC/REST/ZMQ on May 8, 2024
  7. maflcko added the label Resource usage on May 8, 2024
  8. maflcko commented at 10:11 am on May 8, 2024: member

    Did the same check with

    0valgrind --tool=massif ./src/bitcoind &
    1while sleep 3; do ./src/bitcoin-cli getblock 00000000000000000002a7c4c1e48d76c5a37902165a270156b7a8d72728a054 2  ; done
    2
    3...
    4
    5massif-visualizer ./massif.out.1234
    

    out

  9. maflcko commented at 10:11 am on May 8, 2024: member
    Closing for now, as duplicate
  10. maflcko closed this on May 8, 2024

  11. ryanofsky referenced this in commit 0503cbea9a on May 13, 2024
  12. bitcoin locked this on May 8, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-08 21:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me