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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id A3F31BC69 for ; Thu, 6 Dec 2007 13:52:30 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAHx/V0fAXQInh2dsb2JhbACIa4ZtAQEBCAoplGk X-IronPort-AV: E=Sophos;i="4.23,261,1194217200"; d="scan'208";a="20048550" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Dec 2007 13:52:30 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id lB6CqNNA017133 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 6 Dec 2007 13:52:30 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4FAHx/V0dZuyUK/2dsb2JhbACIa5wU X-IronPort-AV: E=Sophos;i="4.23,261,1194217200"; d="scan'208";a="5335778" Received: from unknown (HELO moldavcable.com) ([89.187.37.10]) by mail1-smtp-roc.national.inria.fr with ESMTP; 06 Dec 2007 13:52:22 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by moldavcable.com (Postfix) with ESMTP id 6C82F1E632D; Thu, 6 Dec 2007 14:51:33 +0200 (EET) Received: from moldavcable.com ([127.0.0.1]) by localhost (mlc-gw-l.moldavcable.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13033-04; Thu, 6 Dec 2007 14:51:18 +0200 (EET) Received: from kas30pipe.moldavcable.com (localhost.localdomain [127.0.0.1]) by moldavcable.com (Postfix) with SMTP id 98B261E633A; Thu, 6 Dec 2007 14:51:18 +0200 (EET) Received: from pm053.mlc.local (pm053 [192.168.50.53]) by moldavcable.com (Postfix) with ESMTP id 632321E632D; Thu, 6 Dec 2007 14:51:18 +0200 (EET) Date: Thu, 6 Dec 2007 14:51:25 +0200 From: dmitry grebeniuk X-Mailer: The Bat! (v3.85.02) Home Reply-To: dmitry grebeniuk Organization: Moldavcable X-Priority: 3 (Normal) Message-ID: <1073025434.20071206145125@moldavcable.com> To: Thomas Fischbacher Cc: caml-list@inria.fr Subject: Re: [Caml-list] Questions on replacing finalizers and memory footprints In-Reply-To: <4757D904.2090502@functionality.de> References: <4757D904.2090502@functionality.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-SpamTest-Info: Not protected X-Virus-Scanned: by amavisd-new at moldavcable.com X-Miltered: at concorde with ID 4757F087.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; grebeniuk:01 finalizers:01 footprints:01 arrays:01 runtime:01 ocaml:01 hashtbl:01 walks:98 wrote:01 dmitry:01 dmitry:01 caml-list:01 tuples:01 color:97 bytes:03 Hello, Thomas. TF> Also, is there a simple way to implement a function TF> (perhaps using Obj.magic) which will walk a (possibly TF> circular) network of tuples, arrays, variadic entities TF> and lists, and return the total number of bytes used up TF> by that structure? I see that this should be possible in TF> principle with the present implementation of the runtime TF> if one could get some basic information about the TF> internal type of an array. When I faced this problem, I wrote a function to get the size of value. This is a C-world function which walks though values and marks visited values by changing (and then restoring) their "color". Colors are stored using RLE-like compression to decrease memory usage. But it's possible to calculate the size of the value using pure ocaml code, using Obj to examine values and Hashtbl to store visited values. It will work well with small or medium-sized values. -- WBR, dmitry mailto:gds-mlsts@moldavcable.com