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

Member
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

Member
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