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

From: Guy Albertelli II <[email-masked]>
Date: Thu, 8 Dec 2005 09:10:30 -0500 (EST)

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.

use Safe;

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

-- 
[email-masked]   0-7-1-9-27,137

---

From: Jeremy Bowers <[email-masked]>
Date: Thu, 08 Dec 2005 11:55:50 -0500

> memory on my machine after 4800 iterations.

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

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

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

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

     # print "Deleting $package\n";

     Symbol::delete_package($package);
}

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.

---

From: Guy Albertelli II <[email-masked]>
Date: Thu, 8 Dec 2005 13:44:07 -0500 (EST)

Hi Jeremy,

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

Thanks! This will definately make things possible.

But I'm still seeing a small leak with this and perl 5.8.6 (about a
meg every 1000 iterations.)

That I can live with though.

> _______________________________________________
> LON-CAPA-dev mailing list
> [email-masked]
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-dev
>