what the maximum size of an array allowed?
#1 Members - Reputation: 124
Posted 25 October 2011 - 04:54 PM
int[] = new int[100000] ;
thtats ok , but takes a lot of time to create these
i wish to just use
int[20000] , but its some were between 15000 and 20000 it give an error, is there a way to increase this amount to at least 50,000
#2 Members - Reputation: 436
Posted 25 October 2011 - 04:59 PM
i know if you do
int[] = new int[100000] ;
thtats ok , but takes a lot of time to create these
i wish to just use
int[20000] , but its some were between 15000 and 20000 it give an error, is there a way to increase this amount to at least 50,000
This might be language dependent, but in C#, because the size parameter is of type int, it can only be int.MaxValue.
#4 Moderators - Reputation: 7806
Posted 25 October 2011 - 05:49 PM
So don't do that.int[] = new int[100000] ;
thtats ok , but takes a lot of time to create these
Figure out what is slow about it. Is it the time taken to allocate the memory? Is it initialization? (Slow initialization is unlikely, but I suppose it is possible if you have a poor processor and are out of memory.) Consider using one of the container classes instead if it makes sense for your situation.
int[20000] , but its some were between 15000 and 20000 it give an error, is there a way to increase this amount to at least 50,000
What is your error, exactly?
I can allocate 500000 just fine on my machine, rather quickly.
#6 Members - Reputation: 358
Posted 26 October 2011 - 09:24 AM
#7 Members - Reputation: 3284
Posted 26 October 2011 - 09:51 AM
You can generally increase the size of the stack, but its generally much better/easier to simply allocate on the heap ( aka, new ).
#9 Moderator* - Reputation: 5410
Posted 26 October 2011 - 08:59 PM
Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.
#10 Members - Reputation: 5886
Posted 26 October 2011 - 09:00 PM
Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.
That makes no sense. It depends on what you use your array for. The hash table in a chess program is an array with a size of several gigabytes.
To the original question: If you have a hard time defining a large array, you are probably defining it as a local variable (i.e., on the stack). A global array or an array allocated on the heap will allow much larger sizes. If your program takes a long time in something as simple as allocating a smallish array, there's something that needs fixing. Post a short example program so we can see what you are doing. Also, let us know what platform, compiler and compiler settings you are using.
#12 Members - Reputation: 231
Posted 30 October 2011 - 02:12 PM
Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.What?
Oh, I am sorry. I read that wrong. I thought the NUMBER of arrays.. not the size. My apologies.
I don't think thats making any more sense....
Current Project: TechnoFlux read all about it on my
#13 Members - Reputation: 106
Posted 30 October 2011 - 03:14 PM
Have you ever seen anyone seen more than 1000 sets in an array? test[1000]
Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.What?
Oh, I am sorry. I read that wrong. I thought the NUMBER of arrays.. not the size. My apologies.
I don't think thats making any more sense....
#14 Moderator* - Reputation: 5410
Posted 30 October 2011 - 03:43 PM
Have you ever seen anyone seen more than 1000 sets in an array? test[1000]
Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.What?
Oh, I am sorry. I read that wrong. I thought the NUMBER of arrays.. not the size. My apologies.
I don't think thats making any more sense....
Yeah. Have you? What about loading a file into memory? Even if it's only a few kilobytes, it's still a few thousand characters. It's really easy (and not rare at all) to have arrays with lengths more than 1000.
And at any given point in time, applications will often have lots of different arrays. Depending on the application, there can be hundreds of arrays used, each with thousands of elements.
I assume by "sets" you actually mean "elements".
#16 Members - Reputation: 106
Posted 05 November 2011 - 05:56 PM
Yes, elements.I assume by "sets" you actually mean "elements".
Have you ever seen anyone seen more than 1000 sets in an array? test[1000]
Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.What?
Oh, I am sorry. I read that wrong. I thought the NUMBER of arrays.. not the size. My apologies.
I don't think thats making any more sense....
#17 Members - Reputation: 231
Posted 05 November 2011 - 06:18 PM
Have you ever seen anyone seen more than 1000 sets in an array? test[1000]
Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.What?
Oh, I am sorry. I read that wrong. I thought the NUMBER of arrays.. not the size. My apologies.
I don't think thats making any more sense....
I'm doing [2048*2048] right now....
And need multiple arrays or need to stuff a single one with big structs which would be inneficient for the project i'm currently on.
Current Project: TechnoFlux read all about it on my






