caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Warren Harris <warrensomebody@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] RE: understanding weak
Date: Fri, 31 Oct 2008 00:06:33 +0100	[thread overview]
Message-ID: <490A3DF9.5010700@frisch.fr> (raw)
In-Reply-To: <8C745AFA-4FC2-4574-AB97-98321ECC4964@gmail.com>

Warren Harris wrote:
> On Oct 30, 2008, at 11:48 AM, CUOQ Pascal - Pascal.CUOQ@cea.fr wrote:
>> In short: don't use weak pointers to make 
>> caches.
> 
> Thanks for the advice -- but I thought this was exactly what weak hash 
> tables were intended for.

Although there is some similarity between a weak table and a cache 
("store values, but feel free to get rid of them"), they are really 
different beasts: a good implementation of a weak table should release 
memory as soon as possible to avoid memory leak; a good implementation 
of a cache should instead keep data as long as possible (until there is 
a good reason to release it, like resource exhaustion). In particular, 
data stored in a OCaml weak table will be released during the next 
collection cycle when it is no longer referenced by any strong 
reference; this is probably not what you expect from a cache!

-- Alain


  reply	other threads:[~2008-10-30 23:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20081030182019.EEBC5BBB7@yquem.inria.fr>
2008-10-30 18:48 ` CUOQ Pascal
2008-10-30 19:12   ` [Caml-list] " Daniel Bünzli
2008-10-30 19:35   ` Warren Harris
2008-10-30 23:06     ` Alain Frisch [this message]
2008-10-31  8:33       ` Rémi Vanicat
2008-11-01  1:08   ` [Caml-list] " Jon Harrop
2008-11-01 10:37     ` Stefano Zacchiroli
2008-11-01 15:18       ` kirillkh

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=490A3DF9.5010700@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=warrensomebody@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).