mod-alloc 0.9.1

Allocation profiling for Rust. Counters, peak resident, and call-site grouping with inline backtrace capture. Zero external dependencies in the hot path. Lean dhat replacement targeting MSRV 1.75.
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      # Defensive: `dtolnay/rust-toolchain@stable` occasionally reports
      # success on the macos-latest runner image without fully
      # populating `cargo` on PATH (cargo resolves to `rustup-init`
      # instead, causing the next step to die with
      # `error: unexpected argument 'build' found`). Forcing
      # `rustup default stable` here heals that case; the explicit
      # `cargo --version` fails the job loudly with a clear diagnostic
      # if anything is still wrong, instead of leaving the failure
      # buried inside a downstream `cargo build`.
      - name: Verify toolchain is fully installed
        run: |
          rustup show active-toolchain || rustup default stable
          cargo --version
      - uses: Swatinem/rust-cache@v2

      - name: Build (default features)
        run: cargo build --verbose
      - name: Test (default features)
        run: cargo test --verbose

      - name: Build (no default features)
        run: cargo build --no-default-features --verbose

      - name: Build (backtraces feature)
        env:
          RUSTFLAGS: "-C force-frame-pointers=yes"
        run: cargo build --features backtraces --verbose
      - name: Test (backtraces feature)
        env:
          RUSTFLAGS: "-C force-frame-pointers=yes"
        run: cargo test --features backtraces --verbose

      - name: Build (all features)
        env:
          RUSTFLAGS: "-C force-frame-pointers=yes"
        run: cargo build --all-features --verbose
      - name: Test (all features)
        env:
          RUSTFLAGS: "-C force-frame-pointers=yes"
        run: cargo test --all-features --verbose

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - name: Clippy (all features)
        run: cargo clippy --all-targets --all-features -- -D warnings
      - name: Clippy (no default features)
        run: cargo clippy --all-targets --no-default-features -- -D warnings

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --all -- --check

  docs:
    name: Doc build
    runs-on: ubuntu-latest
    env:
      RUSTDOCFLAGS: "-D warnings"
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      # Both feature variants so we catch broken intra-doc links
      # that resolve under one feature set but not another (e.g. a
      # link to a `backtraces`-gated item from the always-on module
      # rustdoc).
      - name: Doc build (default features)
        run: cargo doc --no-deps
      - name: Doc build (all features)
        run: cargo doc --all-features --no-deps

  msrv:
    name: MSRV (Rust 1.75)
    runs-on: ubuntu-latest
    env:
      RUSTFLAGS: "-C force-frame-pointers=yes"
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@1.75
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --all-features --verbose

  asan:
    name: AddressSanitizer (nightly Linux)
    runs-on: ubuntu-latest
    env:
      # ASAN insurance for the unsafe backtrace path. Catches
      # out-of-bounds reads in the FP walker that pass the
      # mandatory range checks but would still be observable to
      # ASAN. Nightly is required because -Zsanitizer is unstable.
      RUSTFLAGS: "-Zsanitizer=address -C force-frame-pointers=yes"
      RUSTDOCFLAGS: "-Zsanitizer=address"
      # Disable use-after-return fake stacks. ASAN's fake-stack
      # mode heap-allocates local variables, which moves them
      # outside the real stack range that `pthread_getattr_np`
      # reports to the walker. The walker is correct; the test
      # would just see local addresses that are not in the
      # reported stack range. We want ASAN to use the real stack
      # so the walker's bounds checks are actually exercised.
      ASAN_OPTIONS: "detect_stack_use_after_return=0"
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: rust-src
      - uses: Swatinem/rust-cache@v2
      - name: Test under ASAN
        run: |
          cargo test --features backtraces --target x86_64-unknown-linux-gnu -Zbuild-std --verbose