Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Mail::Internet memory leaks??

by geektron (Curate)
on Oct 11, 2000 at 04:51 UTC ( [id://36172]=perlquestion: print w/replies, xml ) Need Help??

geektron has asked for the wisdom of the Perl Monks concerning the following question:

I'm boggled. I've tried searching through both Google and DejaNews (c.l.p.misc and c.l.p.modules) for some problem resolution, but since I can't turn anything up, I'm going to ask the Monks.

Seems that processes that use Mail::Internet end up running out of memory. The error isn't reported from the script itself; it comes from the mailserver attempting to contact the alias that handles the auto-responder.

The error message is below ( with the obvious 'violation of security info' changed to protect the innocent, and the guilty):

The original message was received at Tue, 10 Oct 2000 06:05:03 -0700 ( +PDT) from mailer.foo.com [xxx.xxx.xxx.xxx] ----- The following addresses had permanent fatal errors ----- "|<full path removed>autorespond.pl responder" (expanded from: <responder@appserv.foo.com>) ----- Transcript of session follows ----- Out of memory! 554 "|< full path removed>autorespond.pl responder"... unknown mailer error 1
and the code in question:

my $mail = Mail::Internet->new(\*STDIN); my $header = $mail->head; my $to = $mail->get('To'); my $subject = $mail->get('Subject'); my $from = $mail->get('From'); chomp( $to, $subject, $from ); ### some processing logic that says "don't send if =~ /stuff/ my $newbody = &loadMessage; my $rply = Mail::Internet->new(); $rply=$mail->reply(); $rply->replace('From',"nobody\@foo.com"); $rply->replace('Reply-To',"nobody\@foo.com"); $rply->replace('X-Loop','already_processed'); $rply->body("$newbody"); $rply->smtpsend() or die "COuldn't send $!"; undef $rply;

sub loadMessage is just an 'open' statement that returns a text string.

Replies are listed 'Best First'.
RE: Mail::Internet memory leaks??
by geektron (Curate) on Oct 11, 2000 at 07:09 UTC
    UPDATE: in case it isn't clear, i am using both Mail::Internet and Mail::Header

    this is a bit easier than an editor request.

(jcwren) RE: Mail::Internet memory leaks??
by jcwren (Prior) on Oct 11, 2000 at 21:30 UTC
    A few more peices of information would be helpful:

    1. Does the script ever error out with the "COuldn't send $!" message?
    2. Does the script exit gracefully, or at all?
    3. What are the contents of $newbody, and how large is it?
    4. Relevant to #3, have you tried minimizing a test case where you can send any message at all, by hardcoding all the values?
    --Chris

    e-mail jcwren
      A few more pieces of information would be helpful:
      1. Does the script ever error out with the "COuldn't send $!" message?
      Not to my knowledge. All the time I spent testing and debugging (yes, by hand. . . I should probably write something to stress-test it via automatic submissions.)
      2.Does the script exit gracefully, or at all?
      I don't have any error messages from the script. The one I posted comes from sendmail.
      3.What are the contents of $newbody, and how large is it?
      Just text, and the script handles 3 responders, each with text messages ~4K.
      4.Relevant to #3, have you tried minimizing a test case where you can send any message at all, by hardcoding all the values?
      back during coding/testing ( a few months ago now ) yes.

      i should probably, as noted in my response to #1, bang up quick stress-tester and fire ~50 messages at it. see if i can force it to choke. . .

      i really wondered if anyone else has heard of this particular error, so i'd have an extra clue or two . . .

      update # 2

      i threw together a quick stress tester (basically a for loop that sends mail ), and after 150 near-simultaneous messages ( with a ~4K body ) all still runs like a charm.

      so, now i'm looking at the processes on the box, i guess. . .

Re: Mail::Internet memory leaks??
by AgentM (Curate) on Oct 11, 2000 at 21:20 UTC
    If Perl doesn't die or at least freeze, then perl is not running out of memory. perl will let you know well ahead of time when you are out of memory, overflow/ underflow exceptions and all of that other fun stuff that you learned in UNIX programming 101. Try the same script using a test case with output to the screen. perhaps a bug somewhere is hitting an infinite loop? In any case, you will want to view your message and compare that with what you expected. perldebug is certainly a worthwhile option. It is also quite possible that this error is serverside. If you encounter further problems that you decide you can't get around, an alternative would be to pipe the message straight to sendmail. But you sure be sure that what you have now can't be fixed before doing that.
    AgentM Systems or Nasca Enterprises is not responsible for the comments made by AgentM- anywhere.
      His code/output is consistent with a Perl script consuming all available memory under Unix. I've done it before. ("Oops.")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://36172]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-29 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found