Currently I have a TCube
array
CreateCube : array[1..1000] of tcube;
Currently using them as a map so you might have 30 cubes wide, 20 cubes high, thus making a big grid. But 1000 cubes is not really enough for what I need, I need more like 10,000 cubes.
Is having an array this size going to cause issues down the road? Any other options?
The theoretical maximum Java array size is 2,147,483,647 elements. To find the size of a Java array, query an array's length property.
The maximum size of an array is determined by the amount of memory that a program can access. On a 32-bit system, the maximum amount of memory that can be addressed by a pointer is 2^32 bytes which is 4 gigabytes. The actual limit may be less, depending on operating system implementation details.
The maximum allowable array size is 65,536 bytes (64K). Reduce the array size to 65,536 bytes or less. The size is calculated as (number of elements) * (size of each element in bytes).
An array of different things or people is a large number or wide range of them.
There are two main scenarios where large arrays are problematic:
An array can be as large as memory allows. But if it's a local variable, or if you pass it by value to some method, then beware, you can easily get out of stack.
Choosing the right data structure is something I can only advise you on. Much of it will depend on how populated the array will be. A sparse array might well work if the array is large but lightly populated.
Personally, I'd code up a custom list class to contain TCube instances. This has several advantages over an array. Firstly, it will consume memory dynamically. Secondly, you can add additional methods to this class to suit your applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With