Legacy GM Memory usage with DS_Grid

TonyR

Member
All,

Is there any way to calculate how much memory is being used by a ds_grid array? I'm using the grid for tracking perimeters in a roguelike and am debating using one ds_grid for each level (multiple rooms per level), or one ds_grid for the whole dungeon. The data in each cell is only a single 8-bit number.

Thanks
Tony
 

Simon Gust

Member
The grid itself takes some (more than an array though).
What the numbers inside the grid cells are, doesn't matter, a grid cell points to a memory location even if that memory location is empty.

You should be fine regardeless. How large is your dungeon?
~ 1000 x 1000 is no problem
~ 2000 x 2000 is still no problem.
 

TheouAegis

Member
If the data in each cell is only an 8-bit number, use a buffer if you're worried about memory. As Simon said, the grid itself takes up a little memory, and then each of the values it points to takes up 32 or 64 bits. Either method has its pros and cons. Grids are definitely a lot simpler to work with, though.
 
Tony, whatever you do, just make sure you use ds_grid_destroy( your_grid_name ); to delete your grid from memory. You don't want to risk memory leakage in your game.
 
S

Satori

Guest
Since it's a roguelike, are your levels procedurally generated? If so, you can just store the random seed instead of the grid, then use the seed to regenerate the level each time the player visits it. That's what I'm doing in my game and it works great.
 
Top