[CentOS] Limit RAM used by a perl script

Tue Jul 21 18:11:44 UTC 2009
Sean Carolan <scarolan at gmail.com>

> But what if the program's memory use is dependent on lots of factors
> which are not easily predictable.
> And you want to avoid bringing the whole system to it's knees while swapping
> and killing arbritrary other programs while one program is consuming all
> of ram and swap.
> In that case it's easier to limit the memory of that program to e.g. 1 GByte RAM,
> in which normal input usually can be processed without any trouble.  And then,
> when someone feeds the program some bad data which uses exponentially more memory,
> then it gracefully stops, giving a clear error message that this input results in
> too much memory use.
>
> Lots of scenario's for a valid use of such a limit exist.

I'm using the perl-BSD-Resource module, with the script confined to
512MB of RAM. So far it's working fine.  I'm not terribly worried
about the script failing, it's much more important that the server
stay up and running since it is also a production mail server.  If the
script crashes, we can deal with that separately.