Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
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: 2005-10-14 (09:32)
From: Richard Jones <rich@a...>
Subject: Memory usage/ garbage collection question

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

  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.


Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology -
Team Notepad - intranets and extranets for business -