From: Markus Mottl <markus@oefai.at>
To: onlyclimb <onlyclimb@163.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Why always out_of _memory
Date: Fri, 20 Dec 2002 14:30:22 +0100 [thread overview]
Message-ID: <20021220133022.GB18442@fichte.ai.univie.ac.at> (raw)
In-Reply-To: <3E038031.2030005@163.com>
On Fri, 20 Dec 2002, onlyclimb wrote:
> why i always encounter out_of_memory error?
> 1 let mem_leaves tr n = let lf = Res.Array.to_array tr.leaves in
> 2 try
> 3 for i = 0 to Array.length lf -1 do
> 4 if n = lf.(i) then raise Exit
> 5 done; false
> 6 with Exit -> true
I guess that your leaves are part of cycles. Thus, the comparison function
may get into troubles...
E.g.:
type t = { a : t; b : unit }
let rec x = { a = x; b = () }
let rec y = { a = y; b = () }
let _ = print_endline (string_of_bool (x = y))
The above code will lead to "Out of memory".
Note that putting "b : unit" first in the type definition just leads
to non-termination, because the comparison function can finish on the
first field and descend tail-recursively into the second part, thus
looping forever.
Further note: comparing "x = x" will finish succesfully, because pointer
equality is always checked for structures.
Regards,
Markus Mottl
--
Markus Mottl markus@oefai.at
Austrian Research Institute
for Artificial Intelligence http://www.oefai.at/~markus
-------------------
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
prev parent reply other threads:[~2002-12-20 13:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-20 20:40 onlyclimb
2002-12-20 13:30 ` Markus Mottl [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=20021220133022.GB18442@fichte.ai.univie.ac.at \
--to=markus@oefai.at \
--cc=caml-list@inria.fr \
--cc=onlyclimb@163.com \
/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