From: Slickuser on
What's the maximum hash/array in Perl can hold for keys and values?

Thanks.
From: A. Sinan Unur on
Slickuser <slick.users(a)gmail.com> wrote in news:fb5a6ceb-5170-41bb-a278-
cc630156869f(a)y18g2000pre.googlegroups.com:

> What's the maximum hash/array in Perl can hold for keys and values?

Please explain what you mean in a little bit more detail. What do you mean
by maximum hash or maximum array?

Sinan
--
A. Sinan Unur <1usa(a)llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
From: xhoster on
Slickuser <slick.users(a)gmail.com> wrote:
> What's the maximum hash/array in Perl can hold for keys and values?

The maximum will depend on arcane details of your perl build. Almost
certainly your machine will run out of memory long, long before you reach
the internal limit, unless you are doing rather silly. Like this:

perl -le '$x[2**31-2]=8;'

It succeeded, but took 16 gig. 2**31-1 runs out of memory. 2**31 gives an
error of Modification of non-creatable array value attempted, subscript
-2147483648 at -e line 1.

Apparently even 64-bit builds use 32-bit ints for array indices.




Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
From: Ilya Zakharevich on
[A complimentary Cc of this posting was sent to

<xhoster(a)gmail.com>], who wrote in article <20080505232209.204$Hk(a)newsreader.com>:
> Slickuser <slick.users(a)gmail.com> wrote:
> > What's the maximum hash/array in Perl can hold for keys and values?
>
> The maximum will depend on arcane details of your perl build. Almost
> certainly your machine will run out of memory long, long before you reach
> the internal limit, unless you are doing rather silly. Like this:
>
> perl -le '$x[2**31-2]=8;'
>
> It succeeded, but took 16 gig. 2**31-1 runs out of memory. 2**31 gives an
> error of Modification of non-creatable array value attempted, subscript
> -2147483648 at -e line 1.
>
> Apparently even 64-bit builds use 32-bit ints for array indices.

Maybe. Also, it looks like the code to convert the size of array to
the size of the buffer-with-pointers-to-scalars defaults to 32-bit
integers for some intermediate values.

Could you report it to p5p as a bug?

Thanks,
Ilya
From: Sherman Pendley on
Slickuser <slick.users(a)gmail.com> writes:

> What's the maximum hash/array in Perl can hold for keys and values?

There is an internal limit to the number of items, but the limit matches
that of a pointer. That is, on 32-bit Perl the limit is 2^32 items, and
the available address space is 2^32 bytes. Since Perl's scalars are always
at least 4 bytes wide, there will therefore never be enough memory to fill
a Perl array or hash to its theoretical maximum capacity.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net