actix-web: HTTP2 memory leak with many concurrent streams

Take the static_index example from https://github.com/actix/examples

cd static_index
cargo run --release 2>/dev/null

And then run h2load -n 1000000 -c 10 -m 200000 http://127.0.0.1:8080/

When the benchmark is done, memory stays used in the server.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 30 (8 by maintainers)

Most upvoted comments

Taking a quick look at this is seems that the issue you’re seeing here is twofold:

  1. Your system allocator is suboptimal, so even after h2load finishes a lot of memory is simply lost to fragmentation. If you switch to jemalloc your memory usage will drop by a lot.
  2. There is some buffer/structure bloat in actix-web itself where even after the test finishes its internal structures (which were previously bloated due to a massive amount of requests) are not shrunk back to their normal size. I’ve attached a flamegraph (courtesy of my memory-profiler; GitHub unfortunately doesn’t allow attaching raw svg so I had to gzip it - just unpack it and open in your web browser) where you can see around ~140MB that was kept allocated long after h2load finished.