Subject: | parts_single_part causes memory leak |
Email::MIME::parts_single_part creates a self-referencing object:
$self->{parts} = [ $self ];
this memory is never freed until the process terminates. For long-lived processes where Email::MIME is used to parts many messages, the leak can be significant.
Here is some code that will output 'ps' for bsd-ish systems:
<snip>
#!/usr/local/bin/perl -w
use strict;
use Email::MIME;
for ( 1 .. 1000 ) {
my $msg = <<'_MESSAGE_';
Date: Mon, 28 Jun 2004 23:22:26 -0600
From: Scott Wiersdorf <scott@perlcode.org>
To: root@nowhere.tld
Subject: Hokey Pokey
Everybody do the hokey pokey.
_MESSAGE_
## this same message parsed with Email::Simple does not leak
Email::MIME->new($msg); ## parse and throw away
printf STDERR "LOOP %2d: %s", $_, `ps -aux | grep $$ | grep -v grep`
unless $_ % 10;
}
exit;
</snip>