Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Is there a penalty for namespace use?

by zentara (Archbishop)
on Dec 30, 2004 at 12:47 UTC ( [id://418245]=note: print w/replies, xml ) Need Help??


in reply to Is there a penalty for namespace use?

Never mind... I found the answer by playing with it. It seems you have to loop thru it a few times for the memory to settle down to a constant value, and since I was using 2 hashes, Perl let it double. However, the following does reclaim memory like I would expect.
#!/usr/bin/perl use warnings; use strict; my %bubs; while(1){ for(1.. 500){ $bubs{$_} = ZtkBubject->new( -name => $_, ); $bubs{$_}=(); delete $bubs{$_}; } %bubs = (); undef %bubs; print "\nCheck memory now and hit enter\n"; <>; } #===================================================================== +======== # ZtkBubject Class #===================================================================== +======== package ZtkBubject; use strict 'vars'; use Carp; sub new { my ($class, %arg) = @_; my $self = { 'name' => $arg{-name}, }; bless $self; # print "just blessed $self\n"; $self->{stuff} = [1..1000]; #add some memory usage return $self; } ############################################# sub DESTROY{ my ($self) = @_; print "destroying->", $self->{name},' ',$self,"\n"; } ########################################### 1;

I'm not really a human, but I play one on earth. flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://418245]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found