hi all,
I am new to Perl and I wrote some code that bascally reads a file that contains information about some host, its ip and a port to which it should connect. A telnet object is first created. the program loops through the file and for each entry tries to connect to the port on a specific machine and expcects specific output. It does so by calling the telnet member function "open".
If the output received is not the one expected, an email message is generated to specific people. At first, I used to call Net::Telnet->new for each entry in the table. That made the program consume about 110M of RAM after running for 4 or 5 hours. I then made a change by creating the telnet object outside of the for loop and only call the "open" function inside.
The program still consumes about 26M of RAM and it's increasing as time passes by. Can anybody enlighten me on how Perl deals with memory management and if there is a better way to implement the task.
Thank you for all the help.
Saad

In reply to Memory leaks by saritto

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.