Version française
Home     About     Download     Resources     Contact us    
Browse thread
Being aware of memory overuse
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Goswin von Brederlow <goswin-v-b@w...>
Subject: Re: [Caml-list] Re: Being aware of memory overuse
Sylvain Le Gall <sylvain@le-gall.net> writes:

> On 05-02-2010, David Rajchenbach-Teller <David.Teller@mlstate.com> wrote:
>>        Dear list,
>>  I'm writing some code that needs to be able to cope nicely with
>>  memory exhaustion. That is, it should be able to detect at some point
>>  if it is getting close to exhausting memory, and take the necessary
>>  course of action (e.g. bailing out nicely). I'm wondering what's the
>>  best way of doing this. I've been thinking about installing a
>>  [Gc.alarm] and checking [Gc.free_words], [Gc.free_blocks],
>>  [Gc.largest_free] just after each major cycle, but I'm wondering if
>>  it's the best technique.
>>
>> Any suggestion?
>>
>
> I worked on this subject, for a tool that need to use as much memory as
> possible. I started by trying to use Gc module. I ended by reading
> /proc/meminfo and getting/checking data from there. It is fast, simple
> and very precise. In particular, it can take into account other
> processes that take memory.
>
> Regards,
> Sylvain Le Gall

I always wanted to have kernel spport for this. Some way for aplication
to tell the kernel about freeable memory and for the kernel to request
some memory to be freeed instead of swapping it out.

This would be usefull for e.g. a web browser that caches images and
rendered pages in memory for quick redraws and many other applications.

MfG
        Goswin