caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Out-of-memory faults and other cygwin issues
@ 2002-07-11 23:52 Yaron M. Minsky
  2002-07-12  0:15 ` Yaron M. Minsky
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yaron M. Minsky @ 2002-07-11 23:52 UTC (permalink / raw)
  To: caml-list

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.

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. 

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?

Thanks in advance,
y

-- 
|--------/            Yaron M. Minsky              \--------|
|--------\ http://www.cs.cornell.edu/home/yminsky/ /--------|

Open PGP --- KeyID B1FFD916 (new key as of Dec 4th)
Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Out-of-memory faults and other cygwin issues
  2002-07-11 23:52 [Caml-list] Out-of-memory faults and other cygwin issues Yaron M. Minsky
@ 2002-07-12  0:15 ` Yaron M. Minsky
  2002-07-12  1:18 ` Basile STARYNKEVITCH
  2002-07-12 13:58 ` Xavier Leroy
  2 siblings, 0 replies; 5+ messages in thread
From: Yaron M. Minsky @ 2002-07-12  0:15 UTC (permalink / raw)
  To: caml-list

One possibly thing I neglected to mention: I've been compiling with
ocamlopt.

On Thu, 2002-07-11 at 19:52, Yaron M. Minsky wrote:
> 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.
> 
> 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. 
> 
> 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?
> 
> Thanks in advance,
> y
> 
> -- 
> |--------/            Yaron M. Minsky              \--------|
> |--------\ http://www.cs.cornell.edu/home/yminsky/ /--------|
> 
> Open PGP --- KeyID B1FFD916 (new key as of Dec 4th)
> Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916
> 
> -------------------
> 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
-- 
|--------/            Yaron M. Minsky              \--------|
|--------\ http://www.cs.cornell.edu/home/yminsky/ /--------|

Open PGP --- KeyID B1FFD916 (new key as of Dec 4th)
Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Caml-list] Out-of-memory faults and other cygwin issues
  2002-07-11 23:52 [Caml-list] Out-of-memory faults and other cygwin issues 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
  2 siblings, 1 reply; 5+ messages in thread
From: Basile STARYNKEVITCH @ 2002-07-12  1:18 UTC (permalink / raw)
  To: Yaron M. Minsky; +Cc: caml-list

>>>>> "Yaron" == Yaron M Minsky <yminsky@CS.Cornell.EDU> writes:


    Yaron> [...]Another thing I've noticed is that ocaml doesn't seem to
    Yaron> collect memory at the times I expect it to.  In particular,
    Yaron> after clearing all references to the big memory structures
    Yaron> and running Gc.full_major and Gc.collect (in that order),
    Yaron> the memory size (as measured by the Windows task manager)
    Yaron> doesn't immediately go down. [...]

You should also consider running GC.compact 
-- 

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
alias: basile<at>tunes<dot>org 
8, rue de la Faïencerie, 92340 Bourg La Reine, France
-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Out-of-memory faults and other cygwin issues
  2002-07-12  1:18 ` Basile STARYNKEVITCH
@ 2002-07-12  1:22   ` Yaron M. Minsky
  0 siblings, 0 replies; 5+ messages in thread
From: Yaron M. Minsky @ 2002-07-12  1:22 UTC (permalink / raw)
  To: Basile STARYNKEVITCH; +Cc: caml-list

On Thu, 2002-07-11 at 21:18, Basile STARYNKEVITCH wrote:
> >>>>> "Yaron" == Yaron M Minsky <yminsky@CS.Cornell.EDU> writes:
> 
> 
>     Yaron> [...]Another thing I've noticed is that ocaml doesn't seem to
>     Yaron> collect memory at the times I expect it to.  In particular,
>     Yaron> after clearing all references to the big memory structures
>     Yaron> and running Gc.full_major and Gc.collect (in that order),
>     Yaron> the memory size (as measured by the Windows task manager)
>     Yaron> doesn't immediately go down. [...]
> 
> You should also consider running GC.compact 

My mistake.  I meant Gc.compact.  I don't use Gc.collect, and I don't
know that such a call even exists.

y

> -- 
> 
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
> email: basile<at>starynkevitch<dot>net 
> alias: basile<at>tunes<dot>org 
> 8, rue de la Faïencerie, 92340 Bourg La Reine, France
-- 
|--------/            Yaron M. Minsky              \--------|
|--------\ http://www.cs.cornell.edu/home/yminsky/ /--------|

Open PGP --- KeyID B1FFD916 (new key as of Dec 4th)
Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Out-of-memory faults and other cygwin issues
  2002-07-11 23:52 [Caml-list] Out-of-memory faults and other cygwin issues Yaron M. Minsky
  2002-07-12  0:15 ` Yaron M. Minsky
  2002-07-12  1:18 ` Basile STARYNKEVITCH
@ 2002-07-12 13:58 ` Xavier Leroy
  2 siblings, 0 replies; 5+ messages in thread
From: Xavier Leroy @ 2002-07-12 13:58 UTC (permalink / raw)
  To: Yaron M. Minsky; +Cc: caml-list

> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-07-12 13:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-11 23:52 [Caml-list] Out-of-memory faults and other cygwin issues 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 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).