From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 4F46BBB81 for ; Fri, 14 Oct 2005 11:52:59 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j9E9qwJ4007832 for ; Fri, 14 Oct 2005 11:52:58 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA14085 for ; Fri, 14 Oct 2005 11:52:58 +0200 (MET DST) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j9E9qvCT007824 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Fri, 14 Oct 2005 11:52:58 +0200 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1EQMW2-0003zp-00; Fri, 14 Oct 2005 11:10:18 +0100 Date: Fri, 14 Oct 2005 11:10:18 +0100 To: yoann padioleau Cc: caml-list@inria.fr Subject: Re: [Caml-list] Memory usage/ garbage collection question Message-ID: <20051014101018.GA13302@furbychan.cocan.org> References: <5319313.1129282617505.JavaMail.www@wwinf1608> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5319313.1129282617505.JavaMail.www@wwinf1608> User-Agent: Mutt/1.3.28i From: Richard Jones X-Miltered: at nez-perce with ID 434F7FFA.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 434F7FF9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 garbage:01 iter:01 iter:01 garbage:01 pointer:01 heap:01 lazy:01 lazy:01 pxp:01 pxp:01 notepad:01 wrote:01 incremental:01 parsed:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Fri, Oct 14, 2005 at 11:36:57AM +0200, yoann padioleau wrote: > > List.iter ( > > fun row -> > > (* put row into database and forget about it *) > > ) rows; > > (* no further references to rows after this *) > > Because rows is still accessible after the List.iter so it is normal > that it is not garbage collected. I agree that rows is "accessible", but it's not actually used. My understanding is that the GC would be prevented from considering the list for collection if the pointer to the head of the list (ie. rows) was stored on the heap or in a register somewhere. Would this be the case here? > I had the same kind of problem and to optimize it I choose to > produce the elements of rows lazily (but then I had another problem > with the Lazy modudle where elements were not garbage collected so I > use my own lazy module (simple via closure) and it works perfectly > well). Unfortunately this isn't really an option here. The rows list comes from a huge XML doc which is parsed by PXP and passed through some complex post-processing; PXP doesn't support incremental processing of XML docs, and the post-processing would be tricky to convert too. Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com