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

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



On Sat, Oct 31, 2009 at 09:10, Jay Hannah <jay@jays.net> wrote:
> As you process each user/group you can't Cache::FileCache it or shove it
> into a database or something?

That's one possibility.  What I'd like to do is query the ulimit
values at startup, then periodically monitor the size of the variables
(combination of hashes & arrays), and if the memory used reaches a
high-water mark it writes a note to the logfile and then quits
processing right there.  I'd leave it up to the end user to up the
ulimit or high-watermark  settings if they want to process further.

A quick Google for "perl variable size" shows that length() can work
well for scalar variables and can be coaxed into returning the size in
bytes, but doesn't work for hashes and arrays.  It looks like the
"Devel::Size" module is needed for that, but it's not part of the Perl
core module set.  (And some of the comments on PerlMonks.org leads me
to believe it might not be all that stable either...)

I could use Data::Dumper to produce a textual reference stored in a
scalar variable then get it's size.  I'd get a bit of extraneous
characters (i.e. {,},[,],/n," " and = characters), but it would give
some idea when we start climbing in size...

Anyone else have any other ideas?

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)
** *** ***** ******* *********** ************* *****************
*******************