Skip Menu |

This queue is for tickets about the Lingua-EN-NameParse CPAN distribution.

Report information
The Basics
Id: 53669
Status: resolved
Priority: 0/
Queue: Lingua-EN-NameParse

People
Owner: kimryan [...] cpan.org
Requestors: agruber [...] tbi.univie.ac.at
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: severe memory leak
Date: Thu, 14 Jan 2010 00:52:15 +0100
To: bug-Lingua-EN-NameParse [...] rt.cpan.org
From: Andreas Gruber <agruber [...] tbi.univie.ac.at>
Below is a simple linux perl program that shows that this module has some memory leaks: use warnings; use strict; use Lingua::EN::NameParse; for my $i ( 1 .. 100 ) { my %args = ( auto_clean => 1, force_case => 1, lc_prefix => 1, initials => 3, allow_reversed => 1 ); my $parser = new Lingua::EN::NameParse(%args); my $mem = `ps h -o size $$`; chomp($mem); $mem = sprintf( "$i :: %.1f", $mem / 1024 ); print "$mem\n"; } Iteration 1: 4.6 MB Iteration 100: 134.3 MB There seems to be a circular reference somewhere.
I have had this problem reported by several other users. Please refer to the documentation fot the new method: "The C<new> method creates an instance of a name object and sets up the grammar used to parse names. This must be called before any of the following methods are invoked. Note that the object only needs to be created ONCE, and should be reused with new input data. Calling C<new> repeatedly will significantly slow your program down." A huge amount of code gets executed to set up the Parse::RecDescent grammar tree when you call new. But is should only be done once. Calling 'new' inside a loop will make your code much much slower and more memory hungry, but not give you any benefit. Agree that this is aproblem, but can't isolate the problem to my code, Parse::ResDescent or Perl itself. It may be viewed more as a conservative approach to freeing memory than a memory leak, which could point to a Perl interpreter issue.