[Petal] possible memory leak issue

Jonathan Vanasco jon at 2xlp.com
Mon Aug 21 20:19:40 BST 2006


while profiling growth in my modperl app, i read there's a memory  
leak in the way perl handles string evals. i think its fixed in 5.9x  
or so, but it kind of sucks in 5.8.x

i've been stripping them out of my code and restructuring to get  
acceptable performance.

Petal seems to only use it in this section of ::Hash

# import all plugins once
foreach my $include_dir (@INC)
{
     my $dir = "$include_dir/Petal/Hash";
     if (-e $dir and -d $dir)
     {
	opendir DD, $dir or do {
	    warn "Cannot open directory $dir. Reason: $!";
	    next;
	};
	
	my @modules = map { s/\.pm$//; $_ }
	              grep /\.pm$/,
		      grep !/^\./,
		      readdir (DD);
	
	closedir DD;
	
	foreach my $module (@modules)
	{
		$module =~ /^(\w+)$/;
		$module = $1;
		eval "use Petal::Hash::$module";
	    $@ and warn "Cannot import module $module. Reason: $@";
	    $MODIFIERS->{lc ($module) . ':'} = "Petal::Hash::$module";
	}
     }
}



is there any way we can use a non-eval way to do that?

###
use Petal::Hash::String;
	$MODIFIERS->{'string:'}= 'string'
use Petal::Hash::Test;
	$MODIFIERS->{'test:'}= 'test'
use Petal::Hash::Var;
	$MODIFIERS->{'var:'}= 'var'
###

i know that this is done to handle custom plugins- but if someone is  
doing a custom plugin, they're likely to be able to just 'use' the  
module, and the $MODIFIERS line looks like it could just be  
registered in the plugin iteself.




More information about the Petal mailing list