From: Jim Pryor <lists+caml@jimpryor.net>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] memory leak in toplevel? or, how to implement sizeof
Date: Thu, 6 Jan 2011 09:44:06 -0500 [thread overview]
Message-ID: <20110106144406.GD12229@vaio.hsd1.pa.comcast.net> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D94906EC6B@Remus.metastack.local>
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
next prev parent reply other threads:[~2011-01-06 14:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-06 13:05 Jim Pryor
2011-01-06 14:20 ` David Allsopp
2011-01-06 14:44 ` Jim Pryor [this message]
2011-01-06 14:59 ` Jim Pryor
2011-01-07 12:25 ` Damien Doligez
2011-01-07 14:14 ` Jim Pryor
2011-01-07 14:22 ` dmitry grebeniuk
2011-01-06 15:05 ` Pascal Zimmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110106144406.GD12229@vaio.hsd1.pa.comcast.net \
--to=lists+caml@jimpryor.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox