Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Limiting Memory Usage
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-07-14 (03:40)
From: Alexander Fuchs <alexander.fuchs@u...>
Subject: Limiting Memory Usage

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?