bob_dobalina has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: memory leak
by alexlc (Beadle) on Aug 26, 2009 at 01:10 UTC | |
by bob_dobalina (Sexton) on Aug 26, 2009 at 03:31 UTC | |
|
Re: memory leak
by BioLion (Curate) on Aug 26, 2009 at 08:34 UTC | |
by bob_dobalina (Sexton) on Aug 26, 2009 at 16:01 UTC | |
by BioLion (Curate) on Aug 26, 2009 at 18:58 UTC | |
by bob_dobalina (Sexton) on Aug 26, 2009 at 20:08 UTC | |
by BioLion (Curate) on Aug 27, 2009 at 10:55 UTC |