<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/12/c1ae28de1841637e1625891d4f57a4a2"
  from="onlyclimb &lt;onlyclimb@1...&gt;"
  author="onlyclimb"
  date="2002-12-20T12:41:39"
  subject="[Caml-list] Why always out_of _memory"
  prev="2002/12/13a4b0ce13fc355c209086362b0d0710"
  next="2002/12/8d92c73f575ae2ee73062a88a61a3b01"
  next-in-thread="2002/12/78c90ba43648c2c49838d49e891910bc"
  prev-thread="2002/12/d2c2fc4de35ce4234f61c8083211e1fb"
  next-thread="2002/12/756c3fc027fc8ba373e7214c3dba2937"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Why always out_of _memory">
<msg 
  url="2002/12/c1ae28de1841637e1625891d4f57a4a2"
  from="onlyclimb &lt;onlyclimb@1...&gt;"
  author="onlyclimb"
  date="2002-12-20T12:41:39"
  subject="[Caml-list] Why always out_of _memory">
<msg 
  url="2002/12/78c90ba43648c2c49838d49e891910bc"
  from="Markus Mottl &lt;markus@o...&gt;"
  author="Markus Mottl"
  date="2002-12-20T13:30:34"
  subject="Re: [Caml-list] Why always out_of _memory">
</msg>
</msg>
</thread>

<contents>
  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 -&gt; ('a,'b) Node.t -&gt; 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 -&gt; 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                               &lt;|b|&gt;if n = lf.(i) then raise Exit
(ocd) p n
n : ('a, 'b) Node.t = &lt;abstr&gt;
(ocd) p i
i : int = 2
(ocd) p lf
lf : ('a, 'b) Node.t array =
  [|&lt;abstr&gt;; &lt;abstr&gt;; &lt;abstr&gt;; &lt;abstr&gt;; &lt;abstr&gt;; &lt;abstr&gt;|]
(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 -&gt; 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) -&gt; n6(4) -&gt; n7(3) -&gt; n9(3) -&gt; n10(3) -&gt; n8(2) -&gt;
Node at index 3 in lf is : n9(3) -&gt; 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

</contents>

</message>

