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
Manually triggering garbage collection
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-07-29 (13:39)
From: Jean Krivine <jean_krivine@h...>
Subject: Re: [Caml-list] Manually triggering garbage collection
OK great I' ll try,
For the moment I just set a Gc alarm that detects whether memory usage
is above a certain limit and if so, sets the overhead to 0, which
stops completely the memory "leak".
Do you think that would improve to increase the size of the major heap?
Also, do you know how often the alarm is tested? is it each time a
major collection is performed?

Thanks a lot

On Tue, Jul 29, 2008 at 8:53 AM, Damien Doligez <> wrote:
> Hello Jean,
> On 2008-07-26, at 21:15, Jean Krivine wrote:
>> I am running a memory intensive stochastic simulator written in ocaml.
>> After initialization of the data structure (which eats up a lot of
>> memory but that's normal) I observe a memory leak during the
>> simulation which should not be there.
>> I noticed that if I run Gc.major() every n computation events after
>> initialization (I can make n vary), then there is no more memory leak
>> (the memory the process is using is constant).
>> So my question is the following:
>> Is there a rational way to detect I should call for Gc.Major()? (for
>> the moment I am triggering it every n events which is arbitrary)
> This might be a fragmentation problem, but if calling Gc.major()
> fixes it, I guess it's not a true leak (i.e. the memory would stabilize
> at some point).
> At any rate, you might want to try the CVS head version (3.11+dev):
> it uses first-fit allocation in order to fight fragmentation, and I'd
> like to know how well it does in the wild.
> -- Damien