use strict; sub cat($) { my $var = shift; print "cat ($var)\n"; } sub bat($) { my $var=shift; print "bat ($var)\n"; cat($var); } sub apple($) { my $hello=shift; print "Apple ($hello)\n"; bat($hello); } sub recurse($) { my $count=shift; print "0Count = ($count)\n"; if ($count >= 1) { undef($count); print "Leaving...\n"; return; } $count++; recurse($count); } sub recurse1($) { my $count=shift; print "Count1 = ($count)\n"; if ($count >= 1) { undef($count); print "Leaving...\n"; return; } $count++; recurse2($count); } sub recurse2($) { my $count=shift; print "Count2 = ($count)\n"; if ($count >= 1) { undef($count); print "Leaving...\n"; return; } $count++; } print "GetAll Test\n"; use Devel::Leak; my $handle; my $count = Devel::Leak::NoteSV($handle); print "Memory Count Start = ($count)\n"; # this loop is here to test accumulation of memory.. # by increasing the loop max, it does not accumulate # more memory usage.. it _seems_ to reuse....the # results do not change.. for (my $xx=0; $xx< 1; $xx++) { recurse(0); # leaky toilet # recurse1(0); # no leak # apple(1); # no leaks } my $count1= Devel::Leak::CheckSV($handle); my $diff = $count1- $count; print "\nCount = ($count1)\n"; print "Difference in Memory = ($diff)\n"; #=== END----