From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 94569BBAF for ; Wed, 24 Nov 2010 23:43:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuoCAMQj7UzZSMDjgmdsb2JhbACjCRUBAQsLCAcTAx++MIVHBI1vgnA X-IronPort-AV: E=Sophos;i="4.59,250,1288566000"; d="scan'208";a="80153190" Received: from fmmailgate02.web.de ([217.72.192.227]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Nov 2010 23:43:05 +0100 Received: from smtp06.web.de ( [172.20.5.172]) by fmmailgate02.web.de (Postfix) with ESMTP id A5582187750D1; Wed, 24 Nov 2010 23:40:03 +0100 (CET) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #24) id 1PLO0R-0001vx-00; Wed, 24 Nov 2010 23:40:03 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.72) (envelope-from ) id 1PLO0R-0005Vs-2o; Wed, 24 Nov 2010 23:40:03 +0100 From: Goswin von Brederlow To: Edwin Cc: "Kecheng" , caml-list Subject: Re: [Caml-list] OCaml memory leak issue In-Reply-To: <20101124093035.473bd2e5@deb0> ("Edwin"'s message of "Wed, 24 Nov 2010 09:30:35 +0200") References: <201011231954241577004@cecs.pdx.edu> <20101124093035.473bd2e5@deb0> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) Date: Wed, 24 Nov 2010 23:40:03 +0100 Message-ID: <87lj4ipcqk.fsf@frosties.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX18v7ysbPodXl9BuyFfIhsEwP39OMjXq1ihtg1Dk 78aSIDFYzoDOu+SuLyA/mBCguhtCVXw4PvUSWm83c1z0Ugi9gy d4DTJK3cc= X-Spam: no; 0.00; ocaml:01 ocaml:01 byte:01 printf:01 tokens:01 edwin:98 mfg:98 wrote:01 caml-list:01 writes:01 explicitly:02 let:03 let:03 exit:04 exit:04 Török Edwin writes: > On Tue, 23 Nov 2010 19:54:24 -0800 > "Kecheng" wrote: > >> Hi, >> >> I used valgrind to check the memory usage of my OCaml byte code, but >> I found that a memory leak. I'm very confused what the problem is. I >> tried a very simple code as following, and compileed it. >> >> +++++++++++++++++++++++ >> let test = >> let a = 1 in >> let b = a + 5 in >> printf "%d\n" b; >> ;; >> test;; >> +++++++++++++++++++++++ > > I think you need to call the GC on exit explicitly, its not done by > default. > > Best regards, > --Edwin Correct. Ocaml assumes (or knows which OS does) the OS will free all resource at exit anyway. No point wasting valuable time doing a GC sweep. In case of custom blocks and finalize function I believe this to be an error. Managing resources that the OS does not free (IPC tokens, tempfiles, ...) is made much harder due to this. MfG Goswin