From: Jonathan Roewen <jonathan.roewen@gmail.com>
To: caml-list@yquem.inria.fr
Subject: [Caml-list] Garbage Collecting
Date: Sun, 2 Jan 2005 12:04:33 +1300 [thread overview]
Message-ID: <ad8cfe7e05010115045ef0e999@mail.gmail.com> (raw)
Hi,
We're trying to figure out why memory doesn't get collected in our OS
by the OCaml GC, and seems like it doesn't want to reclaim any memory.
We also suspect that Gc.allocated_bytes has a memory leak.
Here is our test case:
(* File mod.ml -- some ``useful'' Caml functions *)
open Printf
let fib (n:int) =1 + n
;;
let mem = ref 0;;
let do_stuff () =
(* making this loop more increases mem usage *)
for i=1 to 900000 do
fib i;
int_of_float (Gc.allocated_bytes()); (* A *)
done;
mem := int_of_float (Gc.allocated_bytes())
;;
let do_results() =
printf "allocated %d\n" !mem;
Gc.full_major(); (* B1 *)
Gc.compact();
Gc.major();
Gc.minor(); (*B2 *)
printf "allocated %d\n" (int_of_float (Gc.allocated_bytes()))
;;
do_stuff ();;
do_results ();;
My results:
Test 1)
allocated 57600272
allocated 57600788
Test 2)
allocated 272
allocated 956
Test 3)
allocated 272
allocated 744
Where test 1 is using the above code; test 2 is with line A commented
out; and test 3 is with both line A and lines B1-B2 commented out.
As you can see from our tests, that invoking the Gc increases memory,
and Gc.allocated_bytes appears to gobble it up like candy.
Would appreciate someone shedding some light on this topic, as writing
our OS in OCaml is going to have some major issues if it won't reclaim
memory.
Regards,
Jonathan
next reply other threads:[~2005-01-01 23:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-01 23:04 Jonathan Roewen [this message]
2005-01-01 23:48 ` Jonathan Roewen
2005-01-01 23:59 ` Olivier Andrieu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad8cfe7e05010115045ef0e999@mail.gmail.com \
--to=jonathan.roewen@gmail.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox