Jump to content

  • Log In with Google      Sign In   
  • Create Account


what the maximum size of an array allowed?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 thedodgeruk   Members   -  Reputation: 124

Like
0Likes
Like

Posted 25 October 2011 - 04:54 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

Sponsor:

#2 arbitus   Members   -  Reputation: 436

Like
0Likes
Like

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.

#3 Serapth   Crossbones+   -  Reputation: 5332

Like
0Likes
Like

Posted 25 October 2011 - 05:04 PM

What language? In C++, 20K is easily doable, even allocated on the stack.

What specifically is the error.

Frankly int[80000] is only like 1/3 a MB on a 32bit system.

#4 frob   Moderators   -  Reputation: 20363

Like
0Likes
Like

Posted 25 October 2011 - 05:49 PM

int[] = new int[100000] ;
thtats ok , but takes a lot of time to create these

So don't do that.

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.
Check out my personal indie blog at bryanwagstaff.com.

#5 Hodgman   Moderators   -  Reputation: 29552

Like
0Likes
Like

Posted 25 October 2011 - 06:34 PM

Are you saying that if you make a large array without using new, then it begins failing with large sizes?
If so, you're probably allocating your array on the stack, which is bad. Large objects should be allocated with new or malloc.

#6 mind in a box   Members   -  Reputation: 568

Like
0Likes
Like

Posted 26 October 2011 - 09:24 AM

If it's slow, have you tried to switch to release mode and to run it without the debugger?

#7 Serapth   Crossbones+   -  Reputation: 5332

Like
0Likes
Like

Posted 26 October 2011 - 09:51 AM

Here are most default stack sizes.

You can generally increase the size of the stack, but its generally much better/easier to simply allocate on the heap ( aka, new ).

#8 weka   Members   -  Reputation: 106

Like
-3Likes
Like

Posted 26 October 2011 - 08:39 PM

I was stupid.

Edited by weka, 12 May 2012 - 06:53 PM.


#9 Cornstalks   Crossbones+   -  Reputation: 6974

Like
0Likes
Like

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.


Posted Image What?
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#10 Álvaro   Crossbones+   -  Reputation: 12946

Like
0Likes
Like

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.



#11 weka   Members   -  Reputation: 106

Like
0Likes
Like

Posted 28 October 2011 - 09:44 PM


Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.


Posted Image What?


Oh, I am sorry. I read that wrong. I thought the NUMBER of arrays.. not the size. My apologies.

#12 menyo   Members   -  Reputation: 407

Like
0Likes
Like

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.


Posted Image 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

DEV BLOG


#13 weka   Members   -  Reputation: 106

Like
0Likes
Like

Posted 30 October 2011 - 03:14 PM




Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.


Posted Image 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....

Have you ever seen anyone seen more than 1000 sets in an array? test[1000]



#14 Cornstalks   Crossbones+   -  Reputation: 6974

Like
0Likes
Like

Posted 30 October 2011 - 03:43 PM





Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.


Posted Image 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....

Have you ever seen anyone seen more than 1000 sets in an array? test[1000]


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".
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#15 way2lazy2care   Members   -  Reputation: 782

Like
0Likes
Like

Posted 30 October 2011 - 03:43 PM

Have you ever seen anyone seen more than 1000 sets in an array? test[1000]

Not only have I seen it, I have done it.

#16 weka   Members   -  Reputation: 106

Like
0Likes
Like

Posted 05 November 2011 - 05:56 PM






Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.


Posted Image 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....

Have you ever seen anyone seen more than 1000 sets in an array? test[1000]

I assume by "sets" you actually mean "elements".

Yes, elements.




#17 menyo   Members   -  Reputation: 407

Like
0Likes
Like

Posted 05 November 2011 - 06:18 PM





Honestly, don't even worry about it. The most people use per array, on average, is probably less than five hundred.


Posted Image 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....

Have you ever seen anyone seen more than 1000 sets in an array? test[1000]



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

DEV BLOG





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS