Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Storable: where is my memory?

by iburrell (Chaplain)
on Dec 12, 2002 at 21:52 UTC ( #219434=note: print w/replies, xml ) Need Help??


in reply to Storable: where is my memory?

You are making lots (2000) of Set::Scalar objects. Then duplicating them needlessly with Storable. Storable probably uses lots of temporary structures. Not to mention the overhead of all the little scalars.

Why are you deep-copying the Set::Scalar object? Why are you using Storable when Set::Scalar includes copy() and clone() methods?

Replies are listed 'Best First'.
Re:^2 Storable: where is my memory?
by ph0enix (Friar) on Dec 13, 2002 at 07:53 UTC

    Well. This piece of code should simulate what goes on when tied hash is used. I have tied hash to PostgreSQL database so key-value pairs are stored in database and does not reside in memory. Because stored values are deeper structures (in most simpliest case the stored value is list of Set::Scalar objects) there is the Storable module used for converting to the scalar.

    There is nfreeze called when storing value to the database and thaw when data retrieval from it. I expect that all temporary variables are freed when goes out of scope, but it looks like not. procinfo function is called when all variables ($tmp, $r_arr, $set and $scalar_set) are out of their scope and so I expect that displayed values should be the same...

    My big problem is memory compsumption when I iterate through all keys in this tied hash. For relatively small piece of test data the first iteration cost about 750 MB and each other cycle causes perl to require about 200 MB more! So after third cycle is allocated more than 1GB!!!

    Simple empty loop with this tied hash which causes memory compsumption...

    while (my ($key, $value) = each %data) { ; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2023-10-01 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?