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 44F8ABBAF for ; Sat, 6 Feb 2010 14:35:03 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlxTAA7/bEtQW+UMgWdsb2JhbACRPooOAQEWJKwFCI0hglcIgXUEhVg X-IronPort-AV: E=Sophos;i="4.49,418,1262559600"; d="scan'208";a="55958710" Received: from lo.gmane.org ([80.91.229.12]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Feb 2010 14:35:02 +0100 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NdkoP-00044f-DC for caml-list@inria.fr; Sat, 06 Feb 2010 14:35:01 +0100 Received: from ks300734.kimsufi.com ([91.121.65.225]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Feb 2010 14:35:01 +0100 Received: from sylvain by ks300734.kimsufi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Feb 2010 14:35:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: Being aware of memory overuse Date: Sat, 6 Feb 2010 13:34:40 +0000 (UTC) Message-ID: References: X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ks300734.kimsufi.com User-Agent: slrn/pre1.0.0-11 (Linux) Sender: news X-Spam: no; 0.00; le-gall:01 wrote:01 data:02 checking:02 checking:02 suggestion:03 module:03 blocks:07 i'm:09 i'm:09 memory:09 memory:09 wondering:09 wondering:09 nicely:10 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