Skip Menu |

This queue is for tickets about the Mail-SPF CPAN distribution.

Report information
The Basics
Id: 89294
Status: open
Priority: 0/
Queue: Mail-SPF

People
Owner: JMEHNLE [...] cpan.org
Requestors: bbkr [...] post.pl
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: v2.8.0
Fixed in: (no value)



Subject: Severe memory leak
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
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?
From: bbkr [...] post.pl
I've put Server creation inside the loop on purpose - that reproduces common situation where Server is used by user classes and each class instance creates new Server object. I'll use "state" feature to reuse Server between instances of my classes. Thanks.