Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: Jim Pryor <lists+caml@jimpryor.net>,
	"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 14:20:38 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D94906EC6B@Remus.metastack.local> (raw)
In-Reply-To: <20110106130539.GB12229@vaio.hsd1.pa.comcast.net>

Jim Pryor wrote:
> Starting up the toplevel fresh, with no .ocamlinit file, I see this:
> 
>     $ /usr/bin/ocaml
>             Objective Caml version 3.12.0
> 
>     # Gc.(compact();counters());;
>     - : float * float * float = (79217., 32932., 82668.)
>     # Gc.(compact();counters());;
>     - : float * float * float = (93530., 32932., 85816.)
>     # Gc.(compact();counters());;
>     - : float * float * float = (107843., 32932., 88964.)
> 
> Why do both the minor_words and major_words keep climbing? Do these
> indicate the number of words _ever_ allocated,

The docs clearly state that is "ever" allocated - see type Gc.stat in the reference manual.

> and so the overhead of
> doing the garbage collection and compacting has pushed them up? Or do they
> indicate the number of words _now_ allocated, so the fact that they
> continue to climb indicates something is leaking memory?

There are all kinds of things going on when you do this - even the result of Gc.counters causes an allocation (it has to create a tuple to return the numbers). The toploop uses the Parsing module to parse each expression and that will result in some allocations. Printf probably allocates as well (which is responsible for the displaying the output in the toploop). If you re-order the variables to do the three statements in a row and then print all nine results at the end then you'll see a rise which looks pretty consistent with just the allocation of your nine variables and the tuples coming from Gc.counters.


David


  reply	other threads:[~2011-01-06 14:24 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 [this message]
2011-01-06 14:44   ` Jim Pryor
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=E51C5B015DBD1348A1D85763337FB6D94906EC6B@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    --cc=lists+caml@jimpryor.net \
    /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