Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: mem usage

by halfcountplus (Hermit)
on May 26, 2010 at 18:05 UTC ( #841771=note: print w/replies, xml ) Need Help??


in reply to Re: mem usage
in thread mem usage

Perl data structures (see PerlGuts Illustrated) need more memory than the mere user data they hold.

Will read. I presumed they used a bit more space, say a few pointers per element for an array -- but that is really really quite a lot.

I've also read somewhere that perl allocates in "power of 2" chunks. So when you add a 2nd element, you get allocated space for 4, then at 5 you get 8, at 9 you get 16 and so on. Is this true?

Replies are listed 'Best First'.
Re^3: mem usage
by ikegami (Pope) on May 26, 2010 at 18:37 UTC

    Close. When it grows, the array size doubles in size plus 4. An array with 1000 scalars in it could take up as much as

    Array overhead + ( 999*2+4 ) * size of a pointer + 1000 * size of the scalars

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://841771]
help
Chatterbox?
[marto]: a security event in the building, police dogs and and so on...
[Discipulus]: a test I hope..
[marto]: just a security event, they have people from the 'corporate' security, external security companies, the police etc

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-11-22 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (317 votes). Check out past polls.

    Notices?