From: skaller <skaller@users.sourceforge.net>
To: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Memory usage/ garbage collection question
Date: Fri, 14 Oct 2005 20:02:54 +1000 [thread overview]
Message-ID: <1129284174.25800.82.camel@rosella> (raw)
In-Reply-To: <20051014094948.GA11039@furbychan.cocan.org>
On Fri, 2005-10-14 at 10:49 +0100, Richard Jones wrote:
> I'm trying to optimise a program which is using a large amount of
> memory and consequently thrashing.
>
> The core of the program is an iteration over a list of something like
> a million elements which consumes about 1/2 gig of RAM. The iteration
> is:
>
> List.iter (
> fun row ->
> (* put row into database and forget about it *)
> ) rows;
> (* no further references to rows after this *)
>
> This is the stdlib implementation of List.iter. Should the garbage
> collector be able to collect the part of the list which has been
> iterated over, during the iteration? At the moment it doesn't look
> like it's doing so.
let rows = ref [] in
(* build up the list of rows here *)
let rec doit rows = match rows with
| [] -> ()
| h :: t -> install_in_db h; doit t (* tail call *)
in
doit (let r = !rows in rows := []; r)
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2005-10-14 10:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-14 9:49 Richard Jones
2005-10-14 10:02 ` skaller [this message]
2005-10-14 10:08 ` [Caml-list] " Olivier Andrieu
[not found] ` <c7ee61120510140258q5b7f393l8e3c2c3d45f49008@mail.gmail.com>
2005-10-14 10:27 ` Richard Jones
2005-10-14 10:51 ` Frederic van der Plancke
-- strict thread matches above, loose matches on Subject: below --
2005-10-14 9:36 yoann padioleau
2005-10-14 10:10 ` Richard Jones
2005-10-14 10:07 ` Gerd Stolpmann
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=1129284174.25800.82.camel@rosella \
--to=skaller@users.sourceforge.net \
--cc=caml-list@inria.fr \
--cc=rich@annexia.org \
/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).