in reply to Memory usage double expected
can someone explain this in a more layman way? I have still many doubts:
# wrong beaviour as it doubles the memory # first code of my previous post, very similar to the OP one my $x = 'a' x (2**30); # RIGHT beaviour, it does NOT double memory used # second code posted above my $x; foreach my $order ( qw(20 24 30 32) ){ $x = 'a' x ( 2 ** $order ); ... # RIGHT beaviour, even with my $x declared inside the foreach loop foreach my $order ( qw(20 24 30 32) ){ my $x = 'a' x ( 2 ** $order ); ...
In addition every perl I have atm ( strawberry portable: 5.26.0 5.22.3 5.24.2 5.26.2 ) I observe the same beahviours of the two above programs, ie. doubled and not doubled; I read also Linux users experience the same. So it must be something really bound to Perl itself and I'd like to know why and how to prevent this: a doubled memory footprint is not such a great feauture to have :)
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Memory usage double expected -- further questions
by bliako (Abbot) on Oct 28, 2022 at 09:23 UTC | |
by LanX (Saint) on Oct 28, 2022 at 10:12 UTC | |
by Discipulus (Canon) on Oct 28, 2022 at 11:44 UTC | |
by dave_the_m (Monsignor) on Oct 28, 2022 at 12:51 UTC | |
by Discipulus (Canon) on Dec 06, 2022 at 11:41 UTC | |
by LanX (Saint) on Oct 28, 2022 at 13:54 UTC |