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 OAA02814; Fri, 20 Dec 2002 14:30:34 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA03826 for ; Fri, 20 Dec 2002 14:30:33 +0100 (MET) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id gBKDUUn11913 for ; Fri, 20 Dec 2002 14:30:30 +0100 (MET) Received: from fichte.ai.univie.ac.at (markus@localhost [127.0.0.1]) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian -4) with ESMTP id gBKDUN6K024767; Fri, 20 Dec 2002 14:30:23 +0100 Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian -4) id gBKDUMCq024766; Fri, 20 Dec 2002 14:30:22 +0100 Date: Fri, 20 Dec 2002 14:30:22 +0100 From: Markus Mottl To: onlyclimb Cc: caml-list@inria.fr Subject: Re: [Caml-list] Why always out_of _memory Message-ID: <20021220133022.GB18442@fichte.ai.univie.ac.at> Mail-Followup-To: onlyclimb , caml-list@inria.fr References: <3E038031.2030005@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E038031.2030005@163.com> User-Agent: Mutt/1.4i Organization: Austrian Research Institute for Artificial Intelligence Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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