Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

what the maximum size of an array allowed?

This topic is 2597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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
[/quote]


What is your error, exactly?

I can allocate 500000 just fine on my machine, rather quickly.

Share this post


Link to post
Share on other sites
Are you saying that if you make a large array without using [font="'Courier New"]new[/font], 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 [font="'Courier New"]new[/font] or [font="'Courier New"]malloc[/font].

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!