From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA24486; Sat, 7 Dec 2002 11:43:11 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA24286 for ; Sat, 7 Dec 2002 11:43:10 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gB7AgbX18372; Sat, 7 Dec 2002 11:42:37 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA24422; Sat, 7 Dec 2002 11:42:37 +0100 (MET) Date: Sat, 7 Dec 2002 11:42:36 +0100 From: Xavier Leroy To: Basile STARYNKEVITCH Cc: David Brown , Caml List Subject: Re: [Caml-list] Memory leak with native code. Message-ID: <20021207114236.B23052@pauillac.inria.fr> References: <20021205184846.GA30014@opus.davidb.org> <15855.46993.822199.934318@hector.lesours> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <15855.46993.822199.934318@hector.lesours>; from basile@starynkevitch.net on Thu, Dec 05, 2002 at 09:31:13PM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > David> I have a fairly complex program that has numerous callbacks > David> between Ocaml, C and back to Ocaml (I'm using Debian's > David> 3.06). > > David> If I compile my program byte-code, it works well. > > David> However, if I compile it native, it seems to leak memory, > David> just consuming more and more memory as it runs. > > I assume your plateform is x86 on Debian. Because of the small number > of registers, tail-recursion is limited to 5 arguments (if my memory > serves me well). For more arguments, a tail-rec is not a loop on x86. As of release 3.06, tail recursion (tail calls to the same function) are properly implemented on all platforms regardless of the number of arguments. Tail cross-recursion, or more generally tail calls to another function, are not supported if the number of arguments is greater than a processor-dependent number: 5 for x86, more for RISC processors. That would explain why a program compiled to native code uses more stack space than when compiled to byte code. However, there is no evidence that David's problem is related to stack space. You can track Caml heap space consumption by running both programs (native and byte-code) with the OCAMLRUNPARAM environment variable set to "v=4". Normally, you should see roughly the same sequences of "Growing heap to ..." messages. A third source of leaks is the C code itself. A good tool to track these leaks is valgrind. - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners