{"id":608600,"date":"2023-02-16T07:48:57","date_gmt":"2023-02-16T13:48:57","guid":{"rendered":"https:\/\/news.sellorbuyhomefast.com\/index.php\/2023\/02\/16\/show-hn-i-wrote-a-tool-in-rust-for-tracking-all-allocations-in-a-linux-process\/"},"modified":"2023-02-16T07:48:57","modified_gmt":"2023-02-16T13:48:57","slug":"show-hn-i-wrote-a-tool-in-rust-for-tracking-all-allocations-in-a-linux-process","status":"publish","type":"post","link":"https:\/\/newsycanuse.com\/index.php\/2023\/02\/16\/show-hn-i-wrote-a-tool-in-rust-for-tracking-all-allocations-in-a-linux-process\/","title":{"rendered":"Show HN: I wrote a tool in Rust for tracking all allocations in a Linux process"},"content":{"rendered":"<div data-target=\"readme-toc.content\">\n<article itemprop=\"text\">\n<p dir=\"auto\"><a target=\"_blank\" rel=\"noopener noreferrer nofollow\" href=\"https:\/\/camo.githubusercontent.com\/97f3918e6f93277e7d23d50ed4ccb2e3c9c94ca79f0d7e77830822fd1c620e72\/68747470733a2f2f616c6c6f6373636f70652e636f6d2f62616e6e65722e706e67\"><img decoding=\"async\" src=\"https:\/\/camo.githubusercontent.com\/97f3918e6f93277e7d23d50ed4ccb2e3c9c94ca79f0d7e77830822fd1c620e72\/68747470733a2f2f616c6c6f6373636f70652e636f6d2f62616e6e65722e706e67\" alt=\"allocscope banner\" data-canonical-src=\"https:\/\/allocscope.com\/banner.png\"><\/a><\/p>\n<h2 dir=\"auto\">allocscope<\/h2>\n<h3 dir=\"auto\">a memory tracking tool<\/h3>\n<p dir=\"auto\">allocscope is a tool for tracking down where the most egregiously large allocations are occurring<br \/>\nin a C, C++ or Rust codebase.  It is particilarly intendend to be useful for developers who want to<br \/>\nget a handle on excessive allocations and are working in a large codebase with multiple<br \/>\ncontributors with allocations occuring in many modules or libraries.<\/p>\n<p dir=\"auto\">It is composed of two commands:<\/p>\n<p dir=\"auto\"><code>allocscope-trace<\/code> attaches to another process as a debugger.  By using breakpoints on memory<br \/>\nallocation functions such as <code>malloc<\/code> it tracks allocations made by that process.  During the<br \/>\ntrace, the callstack of all allocations are recorded to an <code>.atrace<\/code> file.  Tracing programs<br \/>\nwhich spawn multiple threads and tracing calls through shared libraries are supported.  You can<br \/>\nspawn a process to trace by specifying a full commandline to <code>allocscope-trace<\/code>, or you can<br \/>\nattach to an existing running process.<\/p>\n<p dir=\"auto\"><code>allocscope-view<\/code> reads the <code>.atrace<\/code> file produced by <code>allocscope-trace<\/code>.  It presents a summary<br \/>\nof all allocations made in a call tree format, which can be sorted by largest concurrent<br \/>\nallocation, total number of blocks, number of unfreed allocation blocks, or the sequence of<br \/>\nthe allocation.  The summary can be navigated interactively through a curses-based terminal user<br \/>\ninterface, or a text report suitable for non-interactive use can be generated.<\/p>\n<h2 dir=\"auto\">Installing prebuilt binaries<\/h2>\n<p dir=\"auto\">The easiest way to get started with allocscope is to install prebuilt binaries.<\/p>\n<p dir=\"auto\">To install the latest version:<\/p>\n<p dir=\"auto\"><code>curl -s https:\/\/allocscope.com\/install.sh | sudo sh<\/code><\/p>\n<p dir=\"auto\">Currently only Linux on x86_64 processors is supported, but I&#8217;d like to support more operating systems<br \/>\nand processors in the future.<\/p>\n<h2 dir=\"auto\">Getting started<\/h2>\n<p dir=\"auto\">While it will be likely be most useful to use allocscope on a program with symbols, which you<br \/>\nhave compiled yourself, you can verify that it functions correctly by performing a trace on a<br \/>\nstandard system command, such as <code>ls<\/code>:<\/p>\n<div data-snippet-clipboard-copy-content=\"allocscope-trace ls -l\nallocscope-view ls.atrace\"><\/p>\n<pre><code>allocscope-trace ls -l\nallocscope-view ls.atrace\n<\/code><\/pre>\n<\/div>\n<h2 dir=\"auto\">Building from source<\/h2>\n<p dir=\"auto\">On recent Ubuntu releases, allocscope can be built from source with the following sequence<br \/>\nof commands:<\/p>\n<div data-snippet-clipboard-copy-content=\"apt-get update\napt-get install cargo git libclang-dev libiberty-dev libncurses-dev libsqlite3-dev libunwind-dev\ngit clone https:\/\/github.com\/matt-kimball\/allocscope.git\ncd allocscope\ncargo install --path allocscope-trace\ncargo install --path allocscope-view\"><\/p>\n<pre><code>apt-get update\napt-get install cargo git libclang-dev libiberty-dev libncurses-dev libsqlite3-dev libunwind-dev\ngit clone https:\/\/github.com\/matt-kimball\/allocscope.git\ncd allocscope\ncargo install --path allocscope-trace\ncargo install --path allocscope-view\n<\/code><\/pre>\n<\/div>\n<p dir=\"auto\">Statically linked binaries can also be built using the <code>build-static\/build.sh<\/code> script, though this requires<br \/>\nDocker installed on the build system.<\/p>\n<h2 dir=\"auto\">Support development<\/h2>\n<p dir=\"auto\">If you find allocscope useful, please consider supporting development.<\/p>\n<p dir=\"auto\">Visit <a href=\"https:\/\/allocscope.com\/support\" rel=\"nofollow\">https:\/\/allocscope.com\/support<\/a><\/p>\n<h2 dir=\"auto\">License<\/h2>\n<p dir=\"auto\">allocscope is licensed GNU General Public License version 3.<\/p>\n<\/p><\/div>\n<p><a href=\"https:\/\/github.com\/matt-kimball\/allocscope\" class=\"button purchase\" rel=\"nofollow noopener\" target=\"_blank\">Read More<\/a><br \/>\n Tama Pingree<\/p>\n","protected":false},"excerpt":{"rendered":"<p>allocscope a memory tracking tool allocscope is a tool for tracking down where the most egregiously large allocations are occurring in a C, C++ or Rust codebase. It is particilarly intendend to be useful for developers who want to get a handle on excessive allocations and are working in a large codebase with multiple contributors<\/p>\n","protected":false},"author":1,"featured_media":608601,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46,2034,4689],"tags":[],"class_list":{"0":"post-608600","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-technology","8":"category-tracking","9":"category-wrote"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts\/608600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/comments?post=608600"}],"version-history":[{"count":0,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts\/608600\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/media\/608601"}],"wp:attachment":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/media?parent=608600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/categories?post=608600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/tags?post=608600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}