Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Memory usage/ garbage collection question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Memory usage/ garbage collection question
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