caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Baelde <david.baelde@gmail.com>
To: Raoul Duke <raould@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Structural avoidance of memory leaks?
Date: Thu, 10 Feb 2011 15:04:40 +0100	[thread overview]
Message-ID: <AANLkTinaxzYM+n-RjxZyWnvzJA+ogpz1mOHTKez3a+Gr@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikik+m2LnqydT05AqOpjEF06Qm4h3GbRbMyoUGQ@mail.gmail.com>

Hi list,

In my experience, that kind of problem happens with global references.
Of course, there's nothing to worry about with global immutable
things. We often have to use a global register of objects of some kind
(for unique identifiers, maintenance tasks, etc) and we forget that
this global store accumulates data over time and may become the only
reference to an object that should be dead. A simple solution is to
use weak tables when appropriate.

Memory leaks are less likely to be caused by a single function,
because they are generally not long lived, and the programmer of that
function would have in mind how much data it uses. It is possible to
have a function that runs forever and accumulates data (even a pure
function) but it'd generally be visible.

Cheers,
-- 
David

      reply	other threads:[~2011-02-10 14:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09  8:47 David MENTRE
2011-02-09  9:28 ` xclerc
2011-02-09 23:50 ` Raoul Duke
2011-02-10 14:04   ` David Baelde [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=AANLkTinaxzYM+n-RjxZyWnvzJA+ogpz1mOHTKez3a+Gr@mail.gmail.com \
    --to=david.baelde@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=david.baelde@ens-lyon.org \
    --cc=raould@gmail.com \
    /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).