Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many elements can perl hash have?

Tags:

hash

perl

I was wondering if there is a limit to how many elements Perl hash data structure can hold? I am assuming it is probably dependent on how much memory you have available. Does value and key size matter in terms of how many elements it can hold?

like image 256
DoodleKana Avatar asked Dec 27 '22 11:12

DoodleKana


1 Answers

There's no trivial fixed upper bound. It depends on the memory available in the system. If the keys to the hash are bigger, you will run out of memory quicker than if they are smaller. Similarly with the values in the hash; the bigger they are, the sooner you run out of memory.

Generally, the number of elements that will fit in a hash is the least of your problems; if you run out of memory, you should probably be rethinking your algorithm anyway.

like image 123
Jonathan Leffler Avatar answered Jan 13 '23 18:01

Jonathan Leffler