I'm running a script that uses HTML::TreeBuilder and WWW::Mechanize and Mail::Send.

Its purpose is to scan some html and send some notifications to an email.

Now,because it's supposed to run uninterrupted and well over large periods of time without any problems there aren't supposed to be any memory leaks.

Inspite of this,after 1-2 days of running in background on a server it used all the memory on that server,and there was allot of memory on that server(12GB ram) and it also selfishly grabbed all the CPU cycles also(3 CPUs at 1ghz each , each dual-core).

So,this is very unusual for me,it never happened before,this problem happened with perl 5.10.0 I've been looking around some mailing lists and also perlmonks and I think someone else also mentioned that the garbage collection mechanism that perl uses may have some problems(I've found some evidence of people complaining they run scripts and when the scripts exit,they do not release the memory they acquired back to the operating system,that is not very good,altough this doesn't happen to me,the script just hogs memory over here and it releases when it exits).

I would like to add that I have tried to avoid any memory leaks myself or over-consumption by destroying the HTML::TreeBuilder object that I was using.

The only solution that I see know of would be to make a cron job that would close the script after 4-5 hours and restart it back again so that the memory will be realeased.

Questions: Why do you think this is happening ?

Does perl5/perl6 feature any possibility of forcing garbage collection after the programmer knows one variable is not needed any more ?

Best regards,

Stefan


In reply to Gargantuan memory consumption issues by spx2

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.