From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id A4CE0BB81 for ; Sun, 2 Jan 2005 00:04:34 +0100 (CET) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j01N4Xku012892 for ; Sun, 2 Jan 2005 00:04:34 +0100 Received: by rproxy.gmail.com with SMTP id j1so33567rnf for ; Sat, 01 Jan 2005 15:04:33 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=emeJjllOJ/QVD5pM53NaoLgtKEqFzSlf97EF1WP0a3GkIPIitVXaCcWrGCqL8YpROpck40qHqrKpEy3I9Gdbdf1q8ygSay+hlfakmvHn8ADYe4QNSxdaLMt/qKItye0AskAOEB99BcEddq29QfpENw0V2tEw7ISfpnhBGX4LsmA= Received: by 10.39.2.11 with SMTP id e11mr112953rni; Sat, 01 Jan 2005 15:04:33 -0800 (PST) Received: by 10.38.209.53 with HTTP; Sat, 1 Jan 2005 15:04:33 -0800 (PST) Message-ID: Date: Sun, 2 Jan 2005 12:04:33 +1300 From: Jonathan Roewen Reply-To: Jonathan Roewen To: caml-list@yquem.inria.fr Subject: [Caml-list] Garbage Collecting Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41D72C81.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 garbage:01 ocaml:01 printf:01 fib:01 fib:01 printf:01 minor:01 ocaml:01 functions:01 int:01 int:01 caml:02 commented:02 commented:02 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.0 X-Spam-Level: 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