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=AWL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 8C88FBC69 for ; Thu, 6 Dec 2007 15:26:25 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAL+VV0fAXQImh2dsb2JhbACPVwEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.23,261,1194217200"; d="scan'208";a="4961880" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Dec 2007 15:26:25 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lB6EQLak015001 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 6 Dec 2007 15:26:25 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAL+VV0dQRFuw/2dsb2JhbAA X-IronPort-AV: E=Sophos;i="4.23,261,1194217200"; d="scan'208";a="20053372" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Dec 2007 15:26:22 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1J0Hg1-0005Pt-00; Thu, 06 Dec 2007 14:26:09 +0000 Date: Thu, 6 Dec 2007 14:26:09 +0000 To: Thomas Fischbacher Cc: caml-list@inria.fr Subject: Re: [Caml-list] Questions on replacing finalizers and memory footprints Message-ID: <20071206142609.GA15768@furbychan.cocan.org> References: <4757D904.2090502@functionality.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4757D904.2090502@functionality.de> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 4758068D.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; finalizers:01 footprints:01 arrays:01 runtime:01 ocaml:01 ocaml:01 wrote:01 caml-list:01 tuples:01 marshal:01 marshal:01 implemented:02 slightly:03 module:03 module:03 On Thu, Dec 06, 2007 at 11:12:04AM +0000, Thomas Fischbacher 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. You might get some ideas by having a look at the ancient module (http://merjis.com/developers/ancient), specifically at how the C function _mark in ancient_c.c is implemented. Also have a look at the implementation of the Marshal module in the OCaml sources which takes a slightly different approach. If you want to do this in pure OCaml, probably your best bet would be to just Marshal the structure and count how big it is. It'll be slow of course. Rich. -- Richard Jones Red Hat