[LON-CAPA-dev] Math::Complex won't be in 2.1

Jeremy Bowers lon-capa-dev@mail.lon-capa.org
Thu, 08 Dec 2005 11:55:50 -0500

Guy Albertelli II wrote:
> Hi All,
> So I won't be able to include Math::Complex in 2.1.
> Unless someone has some great idea on how to fix that this script is
> up to 1 gig of consumed memory after 2000 iterations, and out of
> memory on my machine after 4800 iterations.

I replicated your results on my machine, and this stops the leak on my 

use Safe;
use Symbol;
use Devel::Symdump;

my $i=0;
while (1)
     my $safe = new Safe;
     $safe->reval('use Math::Complex;');
     if ( $i%10 == 0 ) { print("$i\n"); }

sub delete_package_recurse
     my $package = shift;
     my $Syms = Devel::Symdump->new($package);
     for my $subpackage (keys

     # print "Deleting $package\n";


But it's significantly slower; about 50%, even before you load other 
things into the Safe.

You may not need full recursion in the package deletion, but I tried 
just deleting $safe->{Root}.'Math::Complex', .'Math', and the safe 
space, but that still seemed to leak. I couldn't find a constant set of 
packages I could delete.