Skip to content

dune build -w memory usage grows without bounds when using OCaml syntax in dune files #6900

@copy

Description

@copy

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:

Screenshot_2023-01-18_20-02-57

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

Screenshot_2023-01-18_20-04-14

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions