From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: *** X-Spam-Status: No, score=3.3 required=5.0 tests=AWL,DNS_FROM_RFC_POST, HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id D1112BC37 for ; Tue, 26 May 2009 15:06:12 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai8CABeGG0rRVdyukGdsb2JhbACCIjCUXT8BAQEBCQkMBxEDpiiPOgEDAQSEBwWHBA X-IronPort-AV: E=Sophos;i="4.41,251,1241388000"; d="scan'208";a="28330862" Received: from mail-fx0-f174.google.com ([209.85.220.174]) by mail3-smtp-sop.national.inria.fr with ESMTP; 26 May 2009 15:06:12 +0200 Received: by fxm22 with SMTP id 22so3811102fxm.9 for ; Tue, 26 May 2009 06:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=ws0ZNBaOSQz9bSA3ejozG8T9UKOPudpZD7ahK9PO5Ec=; b=rytlaSjuMWuvtwZSkc9cmchz+5mylGWq3c9y3j0krsrSrgSXUok/4Vv89yoynCpakT nyOv3ESbulKc72U7tMsw39fnKbB7m3GDU5VUHIMhffuIdVusjCOfaoyCcT6M+ay0FBAE lktnYvVXWbDOmOb09ZG1Qqfa/x2s/AqLPYx7A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=J7PtKMJkssZ4EQP7IiPuDqaqN6DsilufR7qDLbyz4LQiw5oQtjt7GjGebzVc9lKS9U o/Ssz8m2UbPPKAqqsCMWkSgSbqF4+thPNmS9CgwlcQvYoOW6mujaNgzrR3ly9QwW9d25 trZRbZzqFKfWGczAyfP7fE+1X/e24meLJhzMw= MIME-Version: 1.0 Sender: gje.hennequin@gmail.com Received: by 10.223.103.207 with SMTP id l15mr4416485fao.2.1243343171142; Tue, 26 May 2009 06:06:11 -0700 (PDT) In-Reply-To: <4A1BE36C.70200@ens-lyon.org> References: <4A1BE36C.70200@ens-lyon.org> Date: Tue, 26 May 2009 15:06:11 +0200 X-Google-Sender-Auth: 3d11be8e91ef779a Message-ID: Subject: Re: [Caml-list] let x = ... in object ... From: Guillaume Hennequin To: Martin Jambon Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001636c5b3ff0ccf2a046ad064c2 X-Spam: no; 0.00; guillaume:01 guillaume:01 endline:01 toplevel:01 val:01 ocaml:01 toplevel:01 cheers:01 endline:01 val:01 ocaml:01 cheers:01 mya:98 mya:98 garbage:01 --001636c5b3ff0ccf2a046ad064c2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit > # class a = let () = print_endline "hello" in object end;; > hello > class a : object end > > > Maybe you mean the following: > > ? well, I have just tested this in the toplevel class a n = let x = Array.make_matrix n n 0. in object(self) val y = Array.init n (fun i -> Array.copy x.(i)) method y = y end ;; let mya = new a 10000 ;; ---------> memory consumption 78.5 (from top) Gc.full_major () ;; ---------> memory consumption is still 78.9 let mya = () ;; Gc.full_major () ;; ---------> memory consumption is now 0.1 Furthermore, in a fresh ocaml toplevel, let x = Array.make_matrix 10000 10000 0. ;; ---------> memory consumption = 39.5 (half of the previous memory usage) So, it seems that x, although not useful after the object creation, is not garbage collected. ?? Cheers Guillaume. --001636c5b3ff0ccf2a046ad064c2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


# class a =3D let () =3D print_endline "hello" in object en= d;;
hello
class a : object =A0end


Maybe you mean the following:


?
well, I have just tes= ted this in the toplevel

class a n =3D
=A0 let x =3D Array.make_= matrix n n 0. in
object(self)
=A0 val y =3D Array.init n (fun i ->= Array.copy x.(i))
=A0 method y =3D y
end ;;

let mya =3D new a 10000 ;;=A0

-= --------> memory consumption 78.5 (from top)

Gc.full_major () ;;<= br>
---------> memory consumption is still 78.9

let mya =3D ()= ;;
Gc.full_major () ;;

---------> memory consumption is now 0.1
<= br>Furthermore, in a fresh ocaml toplevel,
let x =3D Array.make_matrix 1= 0000 10000 0. ;;
---------> memory consumption =3D 39.5
(half of t= he previous memory usage)

So, it seems that x, although not useful after the object creation, is = not garbage collected.

??

Cheers
Guillaume.


--001636c5b3ff0ccf2a046ad064c2--