# Max of an array?

**URL:** <https://www.ruby-forum.com/t/max-of-an-array/171032>\
**Category:** Ruby\
**Created:** [June 25, 2009, 4:24pm UTC](https://www.ruby-forum.com/t/max-of-an-array/171032 "2009-06-25T16:24:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![georgeuoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@georgeuoa](https://www.ruby-forum.com/u/georgeuoa)\
**Post date:** [June 25, 2009, 4:24pm UTC](https://www.ruby-forum.com/t/max-of-an-array/171032/1 "2009-06-25T16:24:42Z")

</div>

what is the maximum size of elements can a ruby array hold and ‘process’  
comfortably for a 1GB RAM machine?

Sorry if this sounds obvious

---

<div class="post-metadata">

**Author:** ![georgeuoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@georgeuoa](https://www.ruby-forum.com/u/georgeuoa)\
**Post date:** [June 25, 2009, 6:20pm UTC](https://www.ruby-forum.com/t/max-of-an-array/171032/2 "2009-06-25T18:20:52Z")

</div>

George G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> what is the maximum size of elements can a ruby array hold and ‘process’  
> comfortably for a 1GB RAM machine?

When you say, “maximum size of elements”, are you referring to the  
size of the individual elements of the array, or the number of items  
in the array? Obviously, the larger the elements, the fewer the count  
for a given amount of memory.

It would be helpful to elaborate on ‘process’ also. If your processing  
is compute intensive, then that could be as much of a bottleneck as  
available memory.

---

<div class="post-metadata">

**Author:** ![georgeuoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@georgeuoa](https://www.ruby-forum.com/u/georgeuoa)\
**Post date:** [June 25, 2009, 8:13pm UTC](https://www.ruby-forum.com/t/max-of-an-array/171032/3 "2009-06-25T20:13:45Z")

</div>

If I would have to take a guess, he refers to the “number of items  
in the array”.

Like, for 1 GIG of RAM, how large would it be, or asked in another way  
if there is an automatical way to find this out for any amount of gig.

---

<div class="post-metadata">

**Author:** ![georgeuoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@georgeuoa](https://www.ruby-forum.com/u/georgeuoa)\
**Post date:** [June 25, 2009, 8:45pm UTC](https://www.ruby-forum.com/t/max-of-an-array/171032/4 "2009-06-25T20:45:52Z")

</div>

On Jun 25, 2009, at 10:24 AM, George G. wrote:

> what is the maximum size of elements can a ruby array hold and  
> ‘process’  
> comfortably for a 1GB RAM machine?

The 1GB real memory constraint doesn’t really help in answering the  
question. The virtual memory size of a process can be much larger than  
the physical memory size of a machine. The manner in which you  
process the data in a large array will greatly affect the performance  
because of the way your algorithm will interact with memory caches and  
virtual memory paging. The amount of memory actually available to  
your process is going to depend on what other processes are running on  
the machine and so on.

Without sharing much more about your particular problem set I’m afraid  
the answer to your question is going to be ‘It depends’. The best way  
to improve on that answer is to experiment with the system in question.

Gary W.
