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 PAA27994; Fri, 12 Jul 2002 15:58:18 +0200 (MET DST) 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 PAA27939 for ; Fri, 12 Jul 2002 15:58:16 +0200 (MET DST) 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 g6CDw9f03636; Fri, 12 Jul 2002 15:58:09 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA27948; Fri, 12 Jul 2002 15:58:09 +0200 (MET DST) Date: Fri, 12 Jul 2002 15:58:09 +0200 From: Xavier Leroy To: "Yaron M. Minsky" Cc: caml-list@inria.fr Subject: Re: [Caml-list] Out-of-memory faults and other cygwin issues Message-ID: <20020712155809.A27285@pauillac.inria.fr> References: <1026431547.1216.46.camel@dragonfly.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <1026431547.1216.46.camel@dragonfly.localdomain>; from yminsky@CS.Cornell.EDU on Thu, Jul 11, 2002 at 07:52:26PM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Does anyone know what triggers ocaml to crash on an "out-of-memory" > error? I'm currently using ocaml on cygwin, and I find that my program > often crashes after the memory size reaches about ~200 megs. This > happened on a machine with a gig of ram and that didn't have all that > much else running. The Caml heap is composed of several largish blocks (about 256 Kb) allocated with malloc(). When the heap is full, a new block is allocated with malloc(); if this fails, the Out_of_memory exception is raised. Apart from this, Out_of_memory can also be raised by the structural comparison functions (=, <>, <, etc) when their internal stack become too large. This can happen if you compare two cyclic or extremely deep data structures. You can get some insight on the cause of an Out_of_memory exception by setting the OCAMLRUNPARAM variable to "v=63". This causes the GC to print a narrative trace of what it's doing. > Another thing I've noticed is that ocaml doesn't seem to collect memory > at the times I expect it to. In particular, after clearing all > references to the big memory structures and running Gc.full_major and > Gc.collect (in that order), the memory size (as measured by the Windows > task manager) doesn't immediately go down. It's possible that I've > neglected to clear my memory references, but I don't think that's it. When a heap block becomes empty (e.g. after GC compaction moved all live objects to other heap blocks), this block is returned *to the C memory allocator* by calling free(). However, many implementations of free() will not return this memory to the OS, but rather keep it around for later use. In this case, external tools like the task manager show no decrease in memory usage. > Another odd and regrettable thing I've noticed about ocaml-on-cygwin is > that when it crashes with a stack error, on cygwin it does so > silently--no error message at all. Anyone know if this is something > that can be worked around? ocamlopt-generated code operates on the system stack, and recovering cleanly from a system stack overflow is very highly OS-dependent. Currently, this is supported only under Linux/x86 and BSD/x86. I haven't figured out how to do it under Cygwin. - 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