I'm working on a 2d adventure game where the player can explore a random generated map. It's working perfectly if I set it to be about 3000x1000 blocks (my array is 3000x1000x2), but this is TOO SMALL. When I want to make a bigger map it trows an OutOfMemory error.
I store my map in a 3d float array where the first two dim shows the position on the world plus I need 2 more data (3rd dim) for each block the type (int blockID) and the stored last update time (float elapsedTime).
Can it be better if I make it 2 separeted 2d array?
This 3d array is the one what is too big and trows OutOfMemory error. The blocks that have made Objects are the ones that can be seen(~32x14 block) the other are just two number ID and elapsedTime.
How should I store the map data?
EDIT:
This code:
int x = 10000;
int y = 10000;
float[][][] ft;
ft = new float[x][y][2];
It trows OutOfMemory error.
float[3000][1000][2]
would just consume about 24 MB. Sure, java being java there can be a lot of hidden memory hogs. But I think you aren't telling us the whole story. Can you show us the declarations of your data structures? \$\endgroup\$