-------------------------------- package Obj; sub new { my $class = shift; my $name = shift; my $value = shift; my $self = { NAME => $obj, VALUE => $value }; bless $self, $class; return $self; } return 1; -------------------------------- # main.pl -------------------------------- my @objects = (); my $i = 0; while($i < 20000000) { @objects = getObjects(); # do something $i += 100; } sub getObjects { my @objects = (); my $object = undef; my %ht = (); # say i use a hash somewhere in here my $i = 0; for($i=0; $i<100; $i++) { $object = new Obj("name_$i", $i); $objects[$i] = $object } return @objects; }