Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Memory usage double expected

by sectokia (Pilgrim)
on Oct 28, 2022 at 05:23 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found