Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: do separate hashes share common keys?

by dave_the_m (Monsignor)
on Feb 14, 2021 at 09:53 UTC ( [id://11128357] : note . print w/replies, xml ) Need Help??


in reply to do separate hashes share common keys?

Yes, each interpreter has what's called the shared string table, which is a big hash which uses every key currently in use by most hashes, using a reference counting mechanism. So if you create 1000 objects with the same key "foobar", there will be a single 'HEK' entry in the shared table for the string "foobar", and all the individual hashes will have a pointer to it.

Note that it is (mostly) unrelated to the Copy-on-Write mechanism.

Dave.

  • Comment on Re: do separate hashes share common keys?

Replies are listed 'Best First'.
Re^2: do separate hashes share common keys?
by LanX (Saint) on Feb 14, 2021 at 13:24 UTC