From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p06Eg0Qr010773 for ; Thu, 6 Jan 2011 15:42:00 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvoAANJiJU1CbwQZkWdsb2JhbACkGRUBAQEBBw0KBxEEIL0vBYVMhGuGIg X-IronPort-AV: E=Sophos;i="4.60,283,1291590000"; d="scan'208";a="84548566" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 06 Jan 2011 15:41:55 +0100 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.messagingengine.com (Postfix) with ESMTP id 16F93213A5 for ; Thu, 6 Jan 2011 09:41:54 -0500 (EST) Received: from frontend2.messagingengine.com ([10.202.2.161]) by compute3.internal (MEProxy); Thu, 06 Jan 2011 09:41:54 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=date:from:to:subject:message-id:references:mime-version:content-type:in-reply-to; s=smtpout; bh=AHq781RKvTjH+EX84iykSpgYCgY=; b=r6YVW2pqN0CtdxYKMoDTpSD2N4VePK2XSH7KRfqx/G43Zk97wSEwLlWqXqF209rMWqYAx6ckTWIi77nAMFI2CQgKpmlIDzOmHaHWDEbldkDvY3llGz+bgMsbmYEwwO6/EGRT0TddcmwFx/+flL73VHRkTv3iOd3+yJPyH/6OlwM= X-Sasl-enc: cJidXZwte9rpb6jHvdwUW1qzhG5U6QVvEbtyPNtcC+mS 1294324913 Received: from localhost (user-12hdvta.cable.mindspring.com [69.22.255.170]) by mail.messagingengine.com (Postfix) with ESMTPSA id BAF9A44617E for ; Thu, 6 Jan 2011 09:41:53 -0500 (EST) Date: Thu, 6 Jan 2011 09:44:06 -0500 From: Jim Pryor To: "caml-list@inria.fr" Message-ID: <20110106144406.GD12229@vaio.hsd1.pa.comcast.net> Mail-Followup-To: "caml-list@inria.fr" References: <20110106130539.GB12229@vaio.hsd1.pa.comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] memory leak in toplevel? or, how to implement sizeof Thanks David. So does this look like a reasonable implementation of sizeof: # let sizeof maker arg = let first = Gc.((stat()).minor_words) in let res = maker arg in let second = Gc.((stat()).minor_words) in int_of_float (second -. first) - 23 ( *overhead *), res;; # sizeof (fun x -> [x]) 1;; - : int * int list = (3, [1]) # sizeof (fun x -> Some x) 1;; - : int * int option = (2, Some 1) It does give the right answers. ([1] is a block containing two non-blocks; Some 1 is a block containing one non-block.) -- Jim Pryor profjim@jimpryor.net