Browse thread
Re: [Caml-list] Memory usage/ garbage collection question
- yoann padioleau
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | yoann padioleau <padator@w...> |
| Subject: | Re: [Caml-list] 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 > 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 > >