in reply to Re: Memory usage double expected
in thread Memory usage double expected
So the simple answer is to avoid having both sides of the 'x' operator as constants. For example, this will fix your situations:
my $VAR = makeA(20000000); sub makeA { return 'A' x (shift) }
This would also fix it:
my $VAR = make20m('A'); sub make20m { return (shift) x 20000000 }
The conclusion seems to be that perl the constant itself occupies memory, and then the variable gets its own copy of the constant.
In Section
Seekers of Perl Wisdom