You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let mem_usage v =
let open Objsize in
let x = objsize v in
show_info ~map:string_of_int x
let () =
let (stream,_) = Lwt_stream.create () in
let rec loop () =
lwt _ = Lwt.pick [
(lwt () = Lwt_unix.sleep 0.1 in Lwt.return ());
(lwt _ = Lwt_stream.get stream in Lwt.return ());
] in
loop ()
in
let tasks = Array.to_list (Array.init 10_000 (fun _ -> loop ())) in
let nr = ref 0 in
let rec memory () =
lwt () = Lwt_unix.sleep 0.05 in
Gc.compact ();
let st = Gc.stat () in
Printf.printf "%d) heap live %d, tasks %s\n%!" !nr st.Gc.live_words (mem_usage tasks);
incr nr;
memory ()
in
Lwt_main.run (Lwt.join (memory () :: tasks))
mem_usage requires objsize, you can remove it's usage and just observe heap growth.
Build with ocamlbuild -use-ocamlfind -tags 'syntax_camlp4o, package(lwt.syntax)' -pkgs lwt.unix,objsize lwt_leak.native
The text was updated successfully, but these errors were encountered:
Thanks for the very nice report. This is fixed in the attached commit. The underlying problem was in Lwt.protected, used internally by Lwt_stream.get. If interested, please see the commit message for details.
mem_usage
requires objsize, you can remove it's usage and just observe heap growth.Build with
ocamlbuild -use-ocamlfind -tags 'syntax_camlp4o, package(lwt.syntax)' -pkgs lwt.unix,objsize lwt_leak.native
The text was updated successfully, but these errors were encountered: