From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA19864 for caml-red; Sat, 10 Feb 2001 22:27:36 +0100 (MET) 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 WAA32441 for ; Fri, 9 Feb 2001 22:36:29 +0100 (MET) Received: from ftp.filemaker.com (ftp.filemaker.com [192.35.50.27]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f19LaSL02778 for ; Fri, 9 Feb 2001 22:36:28 +0100 (MET) Received: from imap.filemaker.com (imap.filemaker.com [17.184.4.101]) by ftp.filemaker.com (8.9.0/8.9.0) with ESMTP id NAA18516 for ; Fri, 9 Feb 2001 13:01:56 -0800 (PST) Received: from [17.184.16.95] ([17.184.16.95]) by imap.filemaker.com (8.9.3/8.9.0) with SMTP id NAA02332 for ; Fri, 9 Feb 2001 13:01:53 -0800 (PST) Message-Id: <200102092101.NAA02332@imap.filemaker.com> Subject: Strange memory leak Date: Fri, 9 Feb 2001 13:08:57 -0800 x-sender: hao-yang_wang@mail.filemaker.com x-mailer: Claris Emailer 2.0v3, January 22, 1998 From: Hao-yang Wang To: Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Sender: weis@pauillac.inria.fr I wrote this bunch of code: ----------------------------------- type 'a zlist = Znull | Zcons of 'a * 'a zzlist and 'a zzlist = 'a zlist Lazy.t let rec zfilter f zz = let z = Lazy.force zz in match z with Znull -> Znull | Zcons(head, ztail) -> if f head then z else zfilter f ztail let rec build_list n = if n > 0 then Zcons(n, lazy (build_list (n - 1))) else Znull let rec loopy f zz = match zfilter f zz with Znull -> () | Zcons(head, ztail) -> loopy f ztail ----------------------------------- >>From the byte-code toplevel, the following expression evaluates fine loopy (fun x -> true) (lazy (build_list 1000000));; while the following expression produces "Fatal error: out of memory." loopy (fun x -> false) (lazy (build_list 1000000));; Why? In particular, the function zfilter looks tail-recursive to me. I am using ocaml-3.00, with the Macintosh version of top-level. Thanks, Hao-yang Wang