I would limit the memory available to the script, with ulimit(1), setrlimit(2), or the program softlimit from the daemontools package.
According to a quick SuperSearch and Google search, you may be able to trap the error with a $SIG{__DIE__} handler if you set the $^M variable:
In reply to Re: Remaining Memory on a system
by sgifford
in thread Remaining Memory on a system
by smellysocks
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |