{"id":17936939,"url":"https://github.com/cppcoffee/rust-memleak","last_synced_at":"2025-09-10T00:35:50.449Z","repository":{"id":259647554,"uuid":"879120029","full_name":"cppcoffee/rust-memleak","owner":"cppcoffee","description":"Tracking Rust application memory usage dynamically.","archived":false,"fork":false,"pushed_at":"2024-11-28T14:27:36.000Z","size":98,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-06T05:02:50.583Z","etag":null,"topics":["aya","ebpf","memleak","rust","uprobes"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cppcoffee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-27T03:15:03.000Z","updated_at":"2024-11-28T14:27:21.000Z","dependencies_parsed_at":"2024-10-27T04:29:48.057Z","dependency_job_id":"ace762d5-fa37-4369-8fc1-d8fd3054f131","html_url":"https://github.com/cppcoffee/rust-memleak","commit_stats":null,"previous_names":["cppcoffee/rust-memleak"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cppcoffee/rust-memleak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Frust-memleak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Frust-memleak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Frust-memleak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Frust-memleak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cppcoffee","download_url":"https://codeload.github.com/cppcoffee/rust-memleak/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Frust-memleak/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274390551,"owners_count":25276406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aya","ebpf","memleak","rust","uprobes"],"created_at":"2024-10-28T22:05:24.599Z","updated_at":"2025-09-10T00:35:50.395Z","avatar_url":"https://github.com/cppcoffee.png","language":"Rust","readme":"# rust-memleak\n\n\n## Prerequisites\n\n1. stable rust toolchains: `rustup toolchain install stable`\n1. nightly rust toolchains: `rustup toolchain install nightly --component rust-src`\n1. (if cross-compiling) rustup target: `rustup target add ${ARCH}-unknown-linux-musl`\n1. (if cross-compiling) LLVM: (e.g.) `brew install llvm` (on macOS)\n1. (if cross-compiling) C toolchain: (e.g.) [`brew install filosottile/musl-cross/musl-cross`](https://github.com/FiloSottile/homebrew-musl-cross) (on macOS)\n1. bpf-linker: `cargo install bpf-linker` (`--no-default-features` on macOS)\n\n\n## Build\n\n```shell\n$ AYA_BUILD_EBPF=true cargo build --release\n```\n\nor\n\n```shell\n$ make\n```\n\n\n## Cross-compiling on macOS\n\nCross compilation should work on both Intel and Apple Silicon Macs.\n\n```shell\nAYA_BUILD_EBPF=true CC=${ARCH}-linux-musl-gcc cargo build --package rust-memleak --release \\\n  --target=${ARCH}-unknown-linux-musl \\\n  --config=target.${ARCH}-unknown-linux-musl.linker=\\\"${ARCH}-linux-musl-gcc\\\"\n```\nThe cross-compiled program `target/${ARCH}-unknown-linux-musl/release/rust-memleak` can be\ncopied to a Linux server or VM and run there.\n\n\n## Notice\n\nThe target Rust application needs to enable stack frame compilation:\n\n```\n$ RUSTFLAGS=\"-C force-frame-pointers=yes\" cargo build\n```\n\n\n## Usage\n\n```shell\nUsage: rust-memleak [OPTIONS] --pid \u003cPID\u003e\n\nOptions:\n  -p, --pid \u003cPID\u003e            pid of the process\n  -b, --bin \u003cBIN\u003e            binary path [optional]\n  -t, --timeout \u003cTIMEOUT\u003e    timeout in seconds [default: 30]\n  -o, --output \u003cOUTPUT\u003e      output file [default: /tmp/memleak.out]\n  -v, --verbose              verbose mode\n  -h, --help                 Print help\n```\n\n\n### Example:\n\n```shell\n# ./target/debug/rust-memleak --pid 20088\n```\n\nGenerating flame graphs:\n\n```shell\n# ./FlameGraph/flamegraph.pl /tmp/memleak.out \u003e /tmp/1.svg\n```\n\nFlame graph:\n\n![flamegraph](images/1.svg)\n\n\n## Reference\n\n[https://github.com/rust-lang/rust/blob/master/library/alloc/src/alloc.rs#L16-L38](https://github.com/rust-lang/rust/blob/master/library/alloc/src/alloc.rs#L16-L38)\n\n[https://github.com/iovisor/bcc/blob/master/libbpf-tools/memleak.bpf.c](https://github.com/iovisor/bcc/blob/master/libbpf-tools/memleak.bpf.c)\n\n[https://github.com/brendangregg/FlameGraph](https://github.com/brendangregg/FlameGraph)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcppcoffee%2Frust-memleak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcppcoffee%2Frust-memleak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcppcoffee%2Frust-memleak/lists"}