#!/usr/bin/perl use warnings; use strict; my %bubs; my %bubs1; for(1.. 500){ $bubs{$_} = ZtkBubject->new( -name => $_, ); $bubs{$_}=(); delete $bubs{$_}; $bubs{$_}=(); } %bubs = (); undef %bubs; print "Check memory now and hit enter\n"; <>; for(1.. 500){ $bubs1{$_} = ZtkBubject->new( -name => $_, ); } print "Check memory now and hit enter, its doubled\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) = @_; @{$self->{stuff}} = (); print "destroying->", $self->{name},' ',$self,"\n"; } ########################################### 1;