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: Sylvain Le Gall <sylvain@l...>
Subject: Re: Being aware of memory overuse
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