Skip to content

out of memory and huge cargo-flamegraph.stacks #439

@mosinnik

Description

@mosinnik

I got simple simple test project with benches that I need to profile (https://github.com/mosinnik/l2_geo_rust)

If run any of follow commands:

cargo flamegraph --profile=bench --bench geo_benchmark -- --bench
cargo flamegraph --bench geo_benchmark -- --bench
cargo flamegraph --bench geo_benchmark -- --bench get_nearest_z_flat

With any of benches durations I got out of memory and huge cargo-flamegraph.stacks. With RUST_BACKTRACE=full :

Error: failed to read dtrace expected output file 'cargo-flamegraph.stacks'

Caused by:
    out of memory

Stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: BaseThreadInitThunk
  11: RtlUserThreadStart

In last try on empty 1tb disk I got 135Gb cargo-flamegraph.stacks file. Last screen before deleted:

Image

windows 10
cargo 1.94.0 (85eff7c80 2026-01-15)
flamegraph-flamegraph 0.6.11
Checked for criterion = "0.5.1" and "0.8"

Main strange thing is that first tries work well - I took flamegrapfs of my 4 benches few times? but after something happen and it broke somehow. Reboots, cleaning, rebuilds, changes dirs - nothing changes

Memory consumption while stack file growing

Image

If I run simple cargo flamegraph --release it work well and I got flamegraph.svg
If I run cargo bench - it work well too

Trying to install dtrace for windows - same thing and almost same error messages:

dtrace: pid 3252 has exited
writing flamegraph to "flamegraph.svg"
Error: unable to generate a flamegraph from the collapsed stack data

Caused by:
    No stack counts found

So as I see problem inside flamegraph

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions