caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: onlyclimb <onlyclimb@163.com>
To: caml-list@inria.fr
Subject: [Caml-list] Why always out_of _memory
Date: Fri, 20 Dec 2002 20:40:17 +0000	[thread overview]
Message-ID: <3E038031.2030005@163.com> (raw)

  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 = <abstr>
(ocd) p i
i : int = 2
(ocd) p lf
lf : ('a, 'b) Node.t array =
  [|<abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>|]
(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


             reply	other threads:[~2002-12-20 12:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-20 20:40 onlyclimb [this message]
2002-12-20 13:30 ` Markus Mottl

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=3E038031.2030005@163.com \
    --to=onlyclimb@163.com \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).