-
Notifications
You must be signed in to change notification settings - Fork 250
Memory leak on completion #1529
Description
With OCaml 4.14 and the latest merlin (4.6-414 and git master (*)), when editing a file in the Irmin repository and querying for completion, the ocamlermlin-server quickly reaches >5go of memory usage in just a few seconds.
To reproduce, it's enough to edit this test file from the Irmin repository and insert a line anywhere, even at the very top:
let _ = Irmin_pack_unix. (* repeatedly ask for completion *)From a quick look with @voodoos, it's not super clear if the typechecker is responsible for holding onto memory for too long, but it contributes to the size of the leak. For example in the test file, removing the functor instantiations in module Store = ... lowers how fast merlin is leaking by a lot. I'm guessing other projects are affected, but that the increasing memory consumption isn't noticeable if one doesn't abuse functors (?)
(*) I believe that @voodoos reproduced the issue on an older version of ocaml/merlin that predates the module shapes