my $code; { my @arr = (9) x 1000_000; $code = sub { @arr }; } # here @arr got out of the scope but is not freed as # there's a ref from inside $code closure # which enables $code do things with the array when called undef $code; # only now that million of nines has gone away # it always existed in exactly one copy