From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q03IMv3o031806 for ; Tue, 3 Jan 2012 19:22:57 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApACAHVGA0/UGyoCkWdsb2JhbAApGoIFqlkiAQEBAQkLCxsDIoFyAQEEAVMlBgsLIRYECwkDAgECAUUTCAEBh3YCBiO1K4h1gxoElQKFT4NNiRk X-IronPort-AV: E=Sophos;i="4.71,451,1320620400"; d="scan'208";a="137708247" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail1-smtp-roc.national.inria.fr with ESMTP; 03 Jan 2012 19:22:51 +0100 Received: from [192.168.1.3] (unknown [82.237.71.191]) by smtp2-g21.free.fr (Postfix) with ESMTP id E71014B014B for ; Tue, 3 Jan 2012 19:22:44 +0100 (CET) Message-ID: <4F03477C.7090706@inria.fr> Date: Tue, 03 Jan 2012 19:22:52 +0100 From: Xavier Leroy User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15 MIME-Version: 1.0 To: caml-list@inria.fr References: <120102000101a0b992e1022cf562e46ade0873e35270@nudt.edu.cn> In-Reply-To: <120102000101a0b992e1022cf562e46ade0873e35270@nudt.edu.cn> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=x-gbk Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Will the data allocated by caml_alloc be automatically freed by g arbage collector? On 01/01/2012 05:01 PM, syshen wrote: > So in this case I think the memory usage of my program should be the same > like before calling minisat_save_proof , because the returned data should be > collected by the garbage collector when exiting the method A to the main loop. > But from the unix "top" command, I find that these huge return data seems to > remain in memory and consume all my memory step by step. There are several possible explanations: 1- Your program is actually keeping a reference to this big piece of data, so it cannot be reclaimed. 2- You're falling into PR#5389, http://caml.inria.fr/mantis/view.php?id=5389 whereas OCaml's compactor can fail to return some memory to the malloc() subsystem. 3- The malloc() implementation on your system elected not to / was unable to return memory to the OS, hence the numbers reported by "top" stay constant. What happens if you run your test in an infinite loop? Does memory usage (as reported by "top") stays constant or increases as a function of time? Only the latter case is really problematic. - Xavier Leroy