Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Memory usage double expected

by sectokia (Pilgrim)
on Oct 28, 2022 at 05:23 UTC ( #11147768=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147768]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2023-09-23 22:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?