New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gc.major () Gc.full_major () bug? #3392
Comments
Comment author: administrator thank you. On Wed, 22 Dec 2004 17:06:34 +0100 (MET), Damien Doligez
|
Comment author: administrator
The problem is automatic triggering of compaction. This is normally done This fix will be available in 3.08.3. With the fix, your program takes a bit Thanks for the bug report. -- Damien |
Comment author: administrator fixed 2004-12-22 DD |
Original bug ID: 3392
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hello
The following code fragment (attached at the end) has drastically
different behaviour when
the Gc.major call in the loop is commented out. As it is written, with
the call to Gc.major,
the programs memory usage tends to grow without bounds and eventually
crash with an Out_of_memory exception ("Raised by primitive operation
at unknown location"). On my
machine, it uses up to 2.5G. When this call is commented out, the
program runs without problems. Still uses a lot of memory 500M, but
the memory usage is bounded.
A call to Gc.full_major () behaves similarly. Gc.minor () and
Gc.compact () do not exhibit this behaviour.
What could be the cause of this bug?
leonid
let protect ~f ~finally =
try
let rval = f () in finally (); rval
with e -> finally (); raise e
let load_value fname =
let f = open_in_bin fname in
protect ~f:(fun () -> input_value f)
~finally:(fun () -> close_in f)
let save_value fname value =
let f =open_out_bin fname in
protect ~f:(fun () -> output_value f value)
~finally:(fun () -> close_out f)
let load_string_list = (load_value : string -> string list)
let save_string_list = (save_value : string -> string list -> unit)
let tname = "/tmp/random_file"
let () =
let list_length = 2500 in
let string_length = 10240 in
let huge_string_list =
Array.to_list (
Array.init list_length (fun i -> String.create string_length))
in
save_string_list tname huge_string_list;
Random.init (int_of_float (Unix.time ()));
for i = 0 to 100000 do
Gc.major ();
let sl = load_string_list tname in
let len = List.length sl in
let c =
String.get
(List.nth sl (Random.int list_length))
(Random.int string_length)
in
Printf.printf "%c %!" c
done;
The text was updated successfully, but these errors were encountered: