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 NAA01788; Fri, 20 Dec 2002 13:41:39 +0100 (MET) 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 NAA01781 for ; Fri, 20 Dec 2002 13:41:29 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from sm181.163.com ([202.108.44.181]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gBKCehH01643 for ; Fri, 20 Dec 2002 13:40:51 +0100 (MET) Received: from localhost (localhost [127.0.0.1]) by sm181.163.com (Postfix) with SMTP id CB2201C6A9FE4 for ; Fri, 20 Dec 2002 20:40:17 +0800 (CST) Received: from 163.com (unknown [159.226.149.121]) by 192.168.1.181 (Coremail) with SMTP id IwMAALEPAz6HH5V5.1 for ; Fri, 20 Dec 2002 20:40:17 +0800 (CST) Message-ID: <3E038031.2030005@163.com> Date: Fri, 20 Dec 2002 20:40:17 +0000 From: onlyclimb User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.1) Gecko/20021005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] Why always out_of _memory Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk why i always encounter out_of_memory error? it is a function of my tree with type type ('a,'b) t ={ mutable name : string ; mutable nodes : ('a,'b) Node.t Res.Array.t ; mutable root : ('a,'b) Node.t; mutable leaves : ('a,'b) Node.t Res.Array.t } val mem_leaves : ('a,'b) t -> ('a,'b) Node.t -> bool 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 for fear that if Res.Array.mem has problem , i change the it into a standard array version using Res.Array.to_array . However , problem still exsits here is the snapshot of ocamldebug just before Out_of_memory error Time : 1070 - pc : 94780 - module Tree 145 <|b|>if n = lf.(i) then raise Exit (ocd) p n n : ('a, 'b) Node.t = (ocd) p i i : int = 2 (ocd) p lf lf : ('a, 'b) Node.t array = [|; ; ; ; ; |] (ocd) s Time : 1071 Program end. Uncaught exception: Out_of_memory Here is the testing code let _ = let tr = maketree in (*make a tree with 6 leaves*) print_newline(); let lf = Tree.get_leaves tr in Res.Array.iter print lf; (* val print : ('a,'b) Node.t -> unit*) print_newline(); let alf = Res.Array.get lf 3 in print_string "Node at index 3 in lf is : "; print alf; let b =Tree.mem_leaves tr alf in (* here throw the out_of_memeroy*) print_string (string_of_bool b) out put is: n5(4) -> n6(4) -> n7(3) -> n9(3) -> n10(3) -> n8(2) -> Node at index 3 in lf is : n9(3) -> Fatal error: exception Out_of_memory here n5 is the node name , (4) is node 's level num it has 6 leaves in the tree I think it is a simple situation. but i dont know where is the problem ? Can anybody help me ? Thanks climb ------------------- 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