sub leak_mem { my $foo; # foo data has one reference, the 'foo' name my $bar; # bar data has one reference, the 'bar' name $foo = \$bar; # bar data has two refs $bar = \$foo; # foo data has two refs return 1; # Oops. foo and bar data reference count are both # decremented by one (because the foo and bar names have # just gone out of scope), but that doesn't take them # to zero. # We just lost some bytes, sir. }