caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: "Yaron M. Minsky" <yminsky@CS.Cornell.EDU>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Out-of-memory faults and other cygwin issues
Date: Fri, 12 Jul 2002 15:58:09 +0200	[thread overview]
Message-ID: <20020712155809.A27285@pauillac.inria.fr> (raw)
In-Reply-To: <1026431547.1216.46.camel@dragonfly.localdomain>; from yminsky@CS.Cornell.EDU on Thu, Jul 11, 2002 at 07:52:26PM -0400

> 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


      parent reply	other threads:[~2002-07-12 13:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-11 23:52 Yaron M. Minsky
2002-07-12  0:15 ` Yaron M. Minsky
2002-07-12  1:18 ` Basile STARYNKEVITCH
2002-07-12  1:22   ` Yaron M. Minsky
2002-07-12 13:58 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020712155809.A27285@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=yminsky@CS.Cornell.EDU \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).