One take away of this discussion is that when you try to reduce a leaking bug due to a scheduler you should be careful not to produce a repro that is not one but just a DOS of your own scheduler (like I did here, it was less obvious in my case since the scheduler is parallel).
Meanwhile, I’m not sure I have nailed down my leak so I’d interested in having more details about what @dinosaure mentioned about possible leaks with effects.
I also have (re?)discovered that Domain.join leaks:
let main () =
for i = 1 to 1_000_000 do
Domain.join (Domain.spawn (fun () -> ()));
Gc.full_major ();
done;
0
let () = if !Sys.interactive then () else exit (main ())
I have a vague remembrance that this is somehow expected but I couldn’t dig up the comment upstream. While you are not supposed to create a million of domains, if you have a test suite exercising thousands of parallel scheduler runs including tear-up/down. It shows up. Perhaps it should at least be documented? Should I open an issue upstream about that (bug or documentation improvement) ?