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=0.0 required=5.0 tests=none 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 8CD10BC69; Fri, 7 Dec 2007 11:34:01 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAO+vWEfAXQImh2dsb2JhbACPVwIBCAop X-IronPort-AV: E=Sophos;i="4.23,265,1194217200"; d="scan'208";a="6578677" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 07 Dec 2007 11:34:00 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lB7AY02S021806 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK); Fri, 7 Dec 2007 11:34:01 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAO+vWEeBrw8Eh2dsb2JhbACPVwIBCAop X-IronPort-AV: E=Sophos;i="4.23,265,1194217200"; d="scan'208";a="4990269" Received: from ext.lri.fr ([129.175.15.4]) by mail2-smtp-roc.national.inria.fr with ESMTP; 07 Dec 2007 11:34:00 +0100 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id AD671A4879; Fri, 7 Dec 2007 11:34:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rPHATJ-cMPyp; Fri, 7 Dec 2007 11:34:00 +0100 (CET) Received: from [129.175.4.117] (lri4-117 [129.175.4.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ext.lri.fr (Postfix) with ESMTP id 9375AA483C; Fri, 7 Dec 2007 11:34:00 +0100 (CET) Message-ID: <4759241C.4070202@lri.fr> Date: Fri, 07 Dec 2007 11:44:44 +0100 From: =?ISO-8859-1?Q?Jean-Christophe_Filli=E2tre?= User-Agent: Thunderbird 1.5.0.14pre (X11/20071023) MIME-Version: 1.0 To: Xavier Leroy Cc: Thomas Fischbacher , caml-list@inria.fr Subject: Re: [Caml-list] Questions on replacing finalizers and memory footprints References: <4757D904.2090502@functionality.de> <475909E8.7010301@inria.fr> In-Reply-To: <475909E8.7010301@inria.fr> X-Enigmail-Version: 0.94.2.0 OpenPGP: url=http://www.lri.fr/~filliatr/mykey.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 47592198.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 finalizers:01 footprints:01 arrays:01 runtime:01 lri:01 filliatr:01 hash:01 hash:01 filliatr:01 wrote:01 caml-list:01 tuples:01 Xavier Leroy wrote: >> Also, is there a simple way to implement a function (perhaps using >> Obj.magic) which will walk a (possibly circular) network of tuples, >> arrays, variadic entities and lists, and return the total number of >> bytes used up by that structure? I see that this should be possible >> in principle with the present implementation of the runtime if one >> could get some basic information about the internal type of an >> array. > > Jean-Christophe Filliātre's "size" library does exactly this: > > http://www.lri.fr/~filliatr/software.en.html Indeed. However, note that it uses internally a hash table to store blocks already considered (in order to correctly account for sharing), and thus it is potentially incorrect if the GC moves some blocks during the count, for instance during a resizing of the hash table (which triggers the GC). I don't know how to avoid this issue; any help is welcome. -- Jean-Christophe Filliātre http://www.lri.fr/~filliatr/