I've got a game that has a grid, which is a 2D array. This array is filled with a struct of information.
struct GridCell
{
uint mCellID;
Vector2 mPosition;
uint mLevel;
int mCellType;
};
class Grid
{
public:
Grid();
~Grid()
protected:
// Heap
GridCell[][] mGridCells;
// Dynamic
GridCell*[][] mGridCells;
};
Keeping in mind that there can be many Grids in memory at once, and that those gridcell can range from very small to very large: Is this better suited to be a heap of gridcells or dynamic (pointer) gridcells?
From what I understand: Heap cells will take up a large chunk of memory Dynamic cells still will, but it will be of pointers, not the entire struct. However, this could lead to fragmented memory?
I'm not sure of which one is the best for this scenario, and I probably don't fully understand the differences between the two either. Help?