[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Self monitoring a perl scripts memory usage...



I have a script that usually maxes out around 100MB of memory (viewed
via /proc/<PID>/status and watching the "VmPeak" value).
In one test case, the complexity of the task grows, and the VmPeak
tops out at over 300MB.  The server this is running on has "ulimit -v
256000" (roughly 256MB), so once the script passes 256MB it is killed.

Questions:
1: Is there a way to let a perl script query itself or the perl
executable to determine how much memory it is currently using?  I'd
like to log the highwater mark at exit so we can watch this over time,
or possibly exit when "250MB" is used and give the user instructions
on upping the limit in a config file after upping the ulimit value.

2: Can the signal be captured in a handler?  If I read chapter 17 of
the OReilly "Learning Perl 3rd Edition", it says that they can't be
trapped... :-(

Thanks,

DanL

-- 
******************* ***************** ************* ***********
******* ***** *** **
"Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from
the Satires of Juvenal
"I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************
*******************