Expected Behavior
dune build -w memory usage should stay below some upper bound over a longer period of time.
Actual Behavior
dune build -w grows without bounds.
Reproduction
Minimal example:
% cat test.ml
% cat dune
(* -*- tuareg -*- *)
open StdLabels
open Jbuild_plugin.V1
let () =
Printf.ksprintf send {|
(executable
(libraries stdlib-shims)
(name test))
|}
% cat dune-project
(lang dune 3.0)
% dune build -w test.exe
In another terminal:
while true; do; echo >> test.ml; sleep 0.1; done
More realistic example:
- In any bigger project, run
git clone https://github.com/ocaml/stdlib-shims.git && git clone https://github.com/mirage/bigarray-compat.git (I believe the presence of dune files containing OCaml syntax is sufficient to trigger their execution and this memory leak)
- Use
dune build -w and make some normal edits
- Observe that the memory usage increases on every edit (in my project, about 25MB per build)
Specifications
- Version of
dune (output of dune --version): 3.6.2
- Version of
ocaml (output of ocamlc --version): 4.14.0 or 5.0
- Operating system (distribution and version): Linux 6.1.6
Additional information
dune --trace-file output:

Memtrace output (added to dune 3.6.2 in bin/main.ml):
