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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 969A5BB84 for ; Fri, 14 Jul 2006 05:40:44 +0200 (CEST) Received: from serv07.divms.uiowa.edu (serv07.divms.uiowa.edu [128.255.44.97]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6E3ehDH013668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 14 Jul 2006 05:40:44 +0200 Received: from [192.168.1.102] (pool-70-107-136-59.ny325.east.verizon.net [70.107.136.59]) by serv07.divms.uiowa.edu with id k6E3eSPb008608 for ; Thu, 13 Jul 2006 22:40:36 -0500 Message-ID: <44B711FC.7000001@uni-koblenz.de> Date: Thu, 13 Jul 2006 23:39:40 -0400 From: Alexander Fuchs User-Agent: Thunderbird 1.5.0.2 (X11/20060516) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Limiting Memory Usage X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.55 on 128.255.44.22 X-Virus-Scanned: ClamAV version 0.88.2, clamav-milter version 0.88.2 on serv07.divms.uiowa.edu X-Virus-Status: Clean X-Miltered: at nez-perce with ID 44B7123B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 terminating:01 resp:01 terminates:01 terminate:01 exceptions:01 cleanup:01 cleanup:01 alexander:03 alexander:03 guess:03 perhaps:04 fuchs:04 fuchs:04 max:05 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hi, I would like to: - limit the max. memory usage of an ocaml program - and do some cleanup and then terminate then program, when this limit is reached. I couldn't see how to do that with the standard libraries, so I added a C-wrapper to use setrlimit with RLIMIT_AS. I guess that works only with Linux, which is not nice but better than nothing. Still, when the memory limit is reached the program just terminates with "Fatal error: out of memory." resp "Out of memory". I couldn't figure out if it is possible to catch any of those errors/exceptions, and do some cleanup before terminating the program. Does perhaps someone know how to provide this functionality in a more satisfactory way? Thanks, Alexander