I'm working on a perpetual program. It runs indefinitly, checking on various servers using ping or SNMP queries. It works like I want it to but it has one major problem. It continualy grabs and uses more ram and process time with each iteration, growing until it become a detriment to the system it's running on.

I have a secondary script, an outside file, that I open and eval. Would this be bloating the memory? This file is simply a hash of data that may change while the script is running. I've set the program up, so that the data can be changed while the script is running.

open(DATA,"data.pl"); while (<DATA>) {$data .= $_;} close DATA; eval $data;
Here's an example of the data it's calling.
@array = ( { label => "backup.hostname.com", status => "on", type => "ping", data => "hostname.com", user => user@hostname.com, error => 'Failed', }, );

But i digress, what I'm looking for is some tutorials on memory management. Where can I find this information, and how can I trim a bloated program while it is running. Similar to undef, but will actually free the memory up for the system.

tyric


In reply to Memory Management in Perl by tyric

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.