Add mallocinfo mode to `getmemoryinfo` RPC #10038

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2017_03_meminfo changing 2 files +54 −7
  1. laanwj commented at 9:12 AM on March 20, 2017: member

    This adds a mode argument to getmemoryinfo. By default the output will remain the same. However if a mode argument of mallocinfo is provided the result of glibc malloc_info (if available) will be returned as a string, as-is.

    This output contains detailed malloc heap statistics, and is useful for tracking heap usage over time or troubleshooting memory fragmentation issues.

  2. laanwj added the label RPC/REST/ZMQ on Mar 20, 2017
  3. Add mallocinfo mode to `getmemoryinfo` RPC
    This adds a mode argument to `getmemoryinfo`. By default the output
    will remain the same. However if a mode argument of `mallocinfo` is
    provided the result of glibc `malloc_info` (if available) will
    be returned as a string, as-is.
    
    This is useful for tracking heap usage over time or troubleshooting
    memory fragmentation issues.
    e141aa4ba6
  4. laanwj force-pushed on Mar 20, 2017
  5. in src/rpc/misc.cpp:544 in e141aa4ba6
     542 | -    return obj;
     543 | +
     544 | +    std::string mode = (request.params.size() < 1 || request.params[0].isNull()) ? "stats" : request.params[0].get_str();
     545 | +    if (mode == "stats") {
     546 | +        UniValue obj(UniValue::VOBJ);
     547 | +        obj.push_back(Pair("locked", RPCLockedMemoryInfo()));
    


    jonasschnelli commented at 10:28 AM on March 20, 2017:

    Don't we need to escape this in some ways? Or is that handled by UniValue?


    laanwj commented at 10:29 AM on March 20, 2017:

    That's handled by UniValue. The whole object is returned as a JSON string. (UniValue has an implicit constructor from string).

  6. laanwj commented at 10:37 AM on March 20, 2017: member

    As for the GLIBC 2.10 symbol requirement, the minimum version of glibc in our symbol checker is 2.11, so this is acceptable for binary releases: https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/symbol-check.py#L43

  7. jonasschnelli commented at 11:17 AM on March 20, 2017: contributor

    Nice. To bad there is no clang equivalent of malloc_info(). This will be linux only. Tested ACK e141aa4ba604ff22c68454112501c166d3e892c9 https://bitcoin.jonasschnelli.ch/build/PR/10038

    <img width="730" alt="bildschirmfoto 2017-03-20 um 12 12 06" src="https://cloud.githubusercontent.com/assets/178464/24097654/206cdb76-0d67-11e7-9668-d06fe13e5f27.png">

    <img width="909" alt="bildschirmfoto 2017-03-20 um 12 16 54" src="https://cloud.githubusercontent.com/assets/178464/24097653/20440b92-0d67-11e7-911d-34cab74d6c70.png">

  8. laanwj commented at 11:32 AM on March 20, 2017: member

    Nice. To bad there is no clang equivalent of malloc_info(). This will be linux only.

    Clang on Linux simply uses glibc. But yeah, other libc's will either have equivalent calls or maybe not, it's specific to the malloc implementation.

  9. fanquake commented at 11:33 AM on March 20, 2017: member

    Tested on OSX ACK e141aa4 screen shot

  10. laanwj merged this on Mar 20, 2017
  11. laanwj closed this on Mar 20, 2017

  12. laanwj referenced this in commit d34995a7ba on Mar 20, 2017
  13. paveljanik commented at 2:15 PM on March 20, 2017: contributor

    postmerge ACK (was merged in the middle of my testing)

  14. laanwj commented at 2:42 PM on March 20, 2017: member

    postmerge ACK (was merged in the middle of my testing)

    Yeah sorry for that, getting this in soon is kind of important due to all the reported OOM issues with 0.14.

  15. TheBlueMatt commented at 6:57 PM on March 20, 2017: member

    postumous utACK e141aa4ba604ff22c68454112501c166d3e892c9

  16. luke-jr commented at 1:35 PM on April 8, 2017: member

    Is there a reason not to just add it as an additional key in the result?

  17. laanwj commented at 1:34 PM on April 10, 2017: member

    Is there a reason not to just add it as an additional key in the result?

    I did that first, but having a huge encoded XML string field in the default JSON object output was ugly. Also this information is potentially slow to compile, so it's better to have it on an separate entry point.

  18. PastaPastaPasta referenced this in commit d77f8e4367 on Mar 10, 2019
  19. PastaPastaPasta referenced this in commit 91e172969a on Mar 11, 2019
  20. PastaPastaPasta referenced this in commit 7f0db68fb8 on Mar 11, 2019
  21. PastaPastaPasta referenced this in commit 59bc53206d on Mar 12, 2019
  22. PastaPastaPasta referenced this in commit c94272a39f on Mar 13, 2019
  23. UdjinM6 referenced this in commit 95f8190cad on Mar 13, 2019
  24. PastaPastaPasta referenced this in commit c46fc27eba on Mar 13, 2019
  25. PastaPastaPasta referenced this in commit 8263fae66c on Mar 14, 2019
  26. PastaPastaPasta referenced this in commit 689584724f on Mar 14, 2019
  27. PastaPastaPasta referenced this in commit dab973a1bd on Mar 15, 2019
  28. PastaPastaPasta referenced this in commit 0b0820f67d on Mar 16, 2019
  29. PastaPastaPasta referenced this in commit 1835de729c on Apr 3, 2019
  30. PastaPastaPasta referenced this in commit e725dcd759 on Apr 3, 2019
  31. PastaPastaPasta referenced this in commit b81760e0dd on Apr 5, 2019
  32. PastaPastaPasta referenced this in commit 1914c2d788 on May 6, 2019
  33. barrystyle referenced this in commit ffe353da75 on Jan 22, 2020
  34. MarcoFalke locked this on Sep 8, 2021

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: 2026-04-13 15:15 UTC

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