on all suspect objects in my code, but it is not reporting anything. does this mean these objects definitely do not have circular references?find_cycle($obj);
Will the array of 100 objects and hash in the sub GetObjs be reclaimed/re-used or will another chunk of memory for 100 objects be taken every call to this sub?-------------------------------- 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; }
I tried adding $db = undef; with no luck. does $db not get re-used every call??use Win32::ODBC; my @objects = (); my $i = 0; while($i < 20000000) { @objects = getObjects(); # do something $i += 100; } sub getObjects { my @objects = (); my $object = undef; my $db = undef; my $i = 0; $db = new Win32::ODBC("DSN=dsnname;UID=username;PWD=pw%") || die; for($i=0; $i<100; $i++) { #$object = new Obj("name_$i", $i); $objects[$i] = $object } if($db) { $db->Close(); } return @objects; }
In reply to memory leak by bob_dobalina
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |