On 2013-10-07 07:24:04, bbkr@post.pl wrote:
Show quoted text> Following code consumes ~16MB of memory per minute on my machine:
>
> perl -MMail::SPF -e 'while(1) {my $s = Mail::SPF::Server->new; my $r =
> Mail::SPF::Request->new("versions" => [ 1, 2 ], "scope" => "mfrom",
> "identity" => "test\@cpan.org", helo_identity => "cpan.org",
> "ip_address" => "199.15.176.140"); my $c = $s->process($r) }'
>
> $ perl -v
> This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-
> linux-gnu-thread-multi
I can reproduce this on …
$ perl -v
This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level
However, instantiating the server object outside the loop fixes it:
perl -MMail::SPF -e 'my $s = Mail::SPF::Server->new; while(1) {my $r = Mail::SPF::Request->new("versions" => [ 1, 2 ], "scope" => "mfrom", "identity" => "test\@cpan.org", helo_identity => "cpan.org", "ip_address" => "199.15.176.140"); my $c = $s->process($r) }'
There's probably a circular reference that prevents the server object from being destroyed inside the loop. I don't have the time to debug this by myself, so unless someone can spend some time on this, my response is: don't create a new server object for every request if you don't have to.
Do you have a good reason to repeatedly recreate a server object?