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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id DEE73BB81 for ; Fri, 14 Oct 2005 11:36:58 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j9E9awaY019496 for ; Fri, 14 Oct 2005 11:36: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 LAA13514 for ; Fri, 14 Oct 2005 11:36:57 +0200 (MET DST) Received: from smtp16.wanadoo.fr (smtp16.wanadoo.fr [193.252.23.89]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j9E9avZN006231 for ; Fri, 14 Oct 2005 11:36:57 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1602.wanadoo.fr (SMTP Server) with ESMTP id 80BB37000047 for ; Fri, 14 Oct 2005 11:36:57 +0200 (CEST) Received: from wwinf1608 (wwinf1608 [172.22.147.51]) by mwinf1602.wanadoo.fr (SMTP Server) with ESMTP id 7D3BC7000044; Fri, 14 Oct 2005 11:36:57 +0200 (CEST) X-ME-UUID: 20051014093657513.7D3BC7000044@mwinf1602.wanadoo.fr Message-ID: <5319313.1129282617505.JavaMail.www@wwinf1608> From: yoann padioleau Reply-To: padator@wanadoo.fr To: Richard Jones , caml-list@inria.fr Subject: Re: [Caml-list] Memory usage/ garbage collection question Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [193.54.76.165] X-Wum-Nature: EMAIL-NATURE X-WUM-FROM: |~| X-WUM-TO: |~||~| X-WUM-REPLYTO: |~| Date: Fri, 14 Oct 2005 11:36:57 +0200 (CEST) X-Miltered: at concorde with ID 434F7C3A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 434F7C39.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 garbage:01 optimise:01 iteration:01 iteration:01 iter:01 stdlib:01 iter:01 garbage:01 iterated:01 lazy:01 lazy:01 notepad:01 caml-list:01 beginner's: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 > 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. Because rows is still accessible after the List.iter so it is normal that it is not garbage collected. 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). > > 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 > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >