/* attempt to deal with prototype, bootstrap, jquery conflicts */ /* for dropdown menus */

### GameDev Marketplace

#### Women's i.make.games T-shirt

$20$15

### Image of the Day Submit

IOTD | Top Screenshots

## 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.

16 replies to this topic

### #1thedodgeruk  Members

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

### #2arbitus  Members

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.

### #3Serapth  Members

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.

### #4frob  Moderators

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

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

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.

### #5Hodgman  Moderators

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.

### #6mind in a box  Members

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?

### #7Serapth  Members

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 ).

### #8weka  Members

Posted 26 October 2011 - 08:39 PM

I was stupid.

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

### #9Cornstalks  Members

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.

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  Members

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.

### #11weka  Members

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.

What?

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

### #12menyo  Members

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

Latest finished project Project

### #13weka  Members

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.

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]

### #14Cornstalks  Members

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.

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 ]

### #15way2lazy2care  Members

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.

### #16weka  Members

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.

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.

### #17menyo  Members

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.

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.

Latest finished project Project

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.