[Melbourne-pm] Finding "Out of memory!"

Bradley Dean bjdean at bjdean.id.au
Thu Oct 2 18:54:12 PDT 2014


Greetings folks,

While looking at a problem where a variety of scripts might develop a
memory leak and fatally terminate with "Out of memory!" I'm trying to
work out if this seemingly simple code is in fact too simple:

package NotifyOnOutOfMemory;
use Errno;
END {
    # If the last errno indicates out of memory perl will now be
    # terminating with "Out of memory!" so tell me about it.
    if ( $! == Errno::ENOMEM ) {
        # Do some low-memory thing that tells me a process has died due
        to memory exhaustion
        # eg. touch /path/to/some/file
        #    or - exec("/path/to/script/which/emails/or/logs $$ $0
        $someOtherDetail")
     }
}
1;

Which would give me a drop in module for scripts with this problem.

What am I missing? :)

Cheerio,

 Brad

-- 
Bradley Dean
Email: bjdean at bjdean.id.au Skype: skype at bjdean.id.au
Mobile(Aus): +61-413014395 WWW: http://bjdean.id.au/


More information about the Melbourne-pm mailing list