in reply to RE: Memory usage in Perl.
in thread Memory usage in Perl.

One detail. Lexical variables do not hand their memory back. Instead perl assumes that it will need to repopulate them again and keeps the memory in use to make it faster to allocate on the next pass through. Unfortunately this can be seen in current versions of Perl in an obscure bug when you declare a my variable inside a one-line if or unless. In particular this sort of thing is seriously unwise:
sub my_func { # Stuff my $foo = $bar unless $cond; # More stuff }
Perl's behaviour in this case is IMO seriously broken, intentionally undocumented, and as Larry Wall put it, "Use of this feature would be erroneous." It is also far more complex than a simple test would indicate.

I would expect it to get fixed, probably for 5.6.2. In the meantime make sure that my statements are guaranteed to be executed.

EDIT
If anyone wants to know more about this, here is an explanation of what exactly is going on, and the original bug report. (*ahem* Yup, that is my bug.)