caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Will the data allocated by caml_alloc be automatically freed by g arbage collector?
Date: Tue, 03 Jan 2012 19:22:52 +0100	[thread overview]
Message-ID: <4F03477C.7090706@inria.fr> (raw)
In-Reply-To: <120102000101a0b992e1022cf562e46ade0873e35270@nudt.edu.cn>

On 01/01/2012 05:01 PM, syshen wrote:

> So in this case I think the memory usage of my program should be the same
> like before calling minisat_save_proof , because the returned data should be
> collected by the garbage collector when exiting the method A to the main loop.
> But from the unix "top" command, I find that these huge return data seems to
> remain in memory and consume all my memory step by step.

There are several possible explanations:

1- Your program is actually keeping a reference to this big piece of
data, so it cannot be reclaimed.

2- You're falling into PR#5389, http://caml.inria.fr/mantis/view.php?id=5389
whereas OCaml's compactor can fail to return some memory to the malloc()
subsystem.

3- The malloc() implementation on your system elected not to / was
unable to return memory to the OS, hence the numbers reported by
"top" stay constant.

What happens if you run your test in an infinite loop?  Does memory
usage (as reported by "top") stays constant or increases as a function
of time?  Only the latter case is really problematic.

- Xavier Leroy

      parent reply	other threads:[~2012-01-03 18:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-01 16:01 syshen
2012-01-03 14:56 ` Romain Bardou
2012-01-03 18:22 ` Xavier Leroy [this message]

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=4F03477C.7090706@inria.fr \
    --to=xavier.leroy@inria.fr \
    --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;
as well as URLs for NNTP newsgroup(s).