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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 7AC7DBC37 for ; Wed, 10 Feb 2010 09:45:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArwBABcBckvZSMDdkGdsb2JhbACaZxUBAQEBCQkMBxMDIK5uCI1gglgIgXUE X-IronPort-AV: E=Sophos;i="4.49,442,1262559600"; d="scan'208";a="56634136" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 Feb 2010 09:45:19 +0100 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id F27FC1468B215; Wed, 10 Feb 2010 09:45:17 +0100 (CET) Received: from [95.208.117.111] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1Nf8CD-0003U9-00; Wed, 10 Feb 2010 09:45:17 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.71) (envelope-from ) id 1Nf8CD-0003NF-6Y; Wed, 10 Feb 2010 09:45:17 +0100 From: Goswin von Brederlow To: Sylvain Le Gall Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Being aware of memory overuse References: Date: Wed, 10 Feb 2010 09:45:17 +0100 In-Reply-To: (Sylvain Le Gall's message of "Sat, 6 Feb 2010 13:34:40 +0000 (UTC)") Message-ID: <876365o4wy.fsf@frosties.localdomain> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+78+RiYwXooKbFo3lGPPA0ZX5Ugze0K51xwles KX+9wVfMaPi85l6BE5J0uzhie+Owy0mCZ8bp06qUDBz0eg29Ld UijFhQCG4= X-Spam: no; 0.00; le-gall:01 mfg:98 wrote:01 caml-list:01 writes:01 data:02 usefull:02 checking:02 checking:02 kernel:02 kernel:02 suggestion:03 module:03 images:93 blocks:07 Sylvain Le Gall writes: > On 05-02-2010, David Rajchenbach-Teller 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