943,695 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 19544
  • C# RSS
Apr 20th, 2006
0

Maximum Array

Expand Post »
Quick question, I know this is actually sorta a stupid question but what is the maximum number of elements in a array?

Not one time has anyone told me a real answer. They all seem to sorta let that question slide by. Also have tired a google search and found nothing related to that.

No it may not simply be a simple number, could is be constrainted to RAM? Just wondering if anyone knows.
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
blacklocist is offline Offline
87 posts
since Apr 2006
Apr 20th, 2006
0

Re: Maximum Array

I couldn't really find anything on it, either. I'm guessing that it really depends on the system. You could probably create as many elements as you could the largest integer on a system would be, considering how that could differ for different platforms, ie, 64 Bit vs 32 bit.

But before that, you'd probably reach the upper limit of memory. Keep in mind that every time you place an object in an array, it allocates a certain amount of memory to that object. So, if an object of type int is 32 bits long, that's how much memory that would be allocated for each element in the array. So, if an array consisted of 500 int objects, then it would be right at around 2KB in size.
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Apr 20th, 2006
0

Re: Maximum Array

Hi,

It is limited with your Virtual Memory Size (if you set to automatic management then it is limited to your free disk space on the drive where your page file resides) I successfully created an array of 100,000,000 int's and the Task manager showed me ~400MB of Virtual Mem usage (I have 512 RAM+512 non-resizable page file) when I created 250,000,000 I got an OS warning saying Virtual Memory too low and for 1,000,000,000 elements the code just gave an Out of Memory error and breaked to IDE.

Loren Soth
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Apr 21st, 2006
0

Re: Maximum Array

Wow, one billion element array. Well thanks for both of your replies!
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
blacklocist is offline Offline
87 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: encapsulating an array in a class?
Next Thread in C# Forum Timeline: problem with login page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC