• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Memory leak (ds_grid, ds_list)

T

TypicalHog

Guest
// Create chunk grid
global.chunk_grid = ds_grid_create(global.grid_width, global.grid_height);
ds_grid_clear(global.chunk_grid, noone);

// Create loader grid
global.loader_list = ds_list_create();
ds_list_clear(global.loader_list);


// Destroy ds_grid and ds_list
ds_grid_destroy(global.chunk_grid);
ds_list_destroy(global.loader_list);


ds_grid and/or ds_map is staying in the memory when the game is restarted for some reason.
 

FrostyCat

Redemption Seeker
Restarting the game doesn't trigger Destroy events, you need to use the Game End event to respond to that.
 

FrostyCat

Redemption Seeker
Then use some sort of replacement game restart script to do the job.
Code:
///_game_restart()
{
  ds_grid_destroy(global.chunk_grid);
  ds_list_destroy(global.loader_list);
  game_restart();
}
 
T

TypicalHog

Guest
Then use some sort of replacement game restart script to do the job.
Code:
///_game_restart()
{
  ds_grid_destroy(global.chunk_grid);
  ds_list_destroy(global.loader_list);
  game_restart();
}
Thank you, it's now solved. Do you think I should destroy all the things this way?
 

FrostyCat

Redemption Seeker
Thank you, it's now solved. Do you think I should destroy all the things this way?
You can, and if you decide to take this route, a cleaner way would be this:
Code:
///_game_restart()
{
  with (all) {
    event_perform(ev_destroy, 0);
  }
  game_restart();
}
What this method doesn't like is Destroy events that have side effects such as playing sounds or spawning other instances. If you have those, you can use user events to store cleanup actions that don't have such side effects, then make both the Destroy event and this script call them.
 
Top