From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 235BABBAF for ; Sat, 11 Apr 2009 22:30:10 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AssAAB+b4EnUnwckjmdsb2JhbACCIZQTAQEBAQcNCAkPBrJAg3wG X-IronPort-AV: E=Sophos;i="4.40,173,1238968800"; d="scan'208";a="26092463" Received: from relay.ptn-ipout02.plus.net ([212.159.7.36]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 11 Apr 2009 22:29:40 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuwEAGua4EnUnw4S/2dsb2JhbACCIccWg3wG Received: from pih-relay05.plus.net ([212.159.14.18]) by relay.ptn-ipout02.plus.net with ESMTP; 11 Apr 2009 21:29:39 +0100 Received: from [87.113.30.188] (helo=leper.local) by pih-relay05.plus.net with esmtp (Exim) id 1Lsjpb-0000ho-8g for caml-list@yquem.inria.fr; Sat, 11 Apr 2009 21:29:39 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OCaml and Boehm Date: Sat, 11 Apr 2009 21:36:13 +0100 User-Agent: KMail/1.9.9 References: <321060.19886.qm@web54109.mail.re2.yahoo.com> In-Reply-To: <321060.19886.qm@web54109.mail.re2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200904112136.13520.jon@ffconsultancy.com> X-Plusnet-Relay: 42fe53605ae1edd45f4468dd511eac85 X-Spam: no; 0.00; ocaml:01 boehm:01 ocaml:01 boehm:01 incorrectly:01 pointers:01 pointers:01 pointer:01 2009:98 stays:98 frog:98 wrote:01 wrote:01 caml-list:01 caml-list:01 On Saturday 11 April 2009 20:17:58 Ed Keith wrote: > --- On Sat, 4/11/09, Jon Harrop wrote: > > From: Jon Harrop > > Subject: Re: [Caml-list] OCaml and Boehm > > To: caml-list@yquem.inria.fr > > Date: Saturday, April 11, 2009, 10:27 AM > > > > Also, don't forget that many people incorrectly claim that smart pointers > > deallocate at the earliest possible point when, in fact, they typically > > keep values alive longer than necessary. > > Could elaborate on this? I'm having a hard time envisioning a situation > where GC could free memory that smart pointers would not free. Smart pointers deallocate when values fall out of scope. GC deallocates when it runs and values are unreachable. Consider: let () = let x = .. f x g() The value "x" stays in scope to the end of the block so a smart pointer will not deallocate it. The GC may well run during "g", realise that "x" is unreachable and deallocate it. Note that there are further unwanted side effects of smart pointers here. Specifically, having to keep "x" around until the end of scope increases register pressure and makes it more likely to values will be spilled, which is a substantial performance cost. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e