GML [SOLVED] is ds_map destroy necessary/did he use it? (ds_map tutorial, Pixelated Pope)

Discussion in 'Programming' started by Dr_Nomz, Jan 10, 2019.

  1. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    552
    Pixelated Pope did an AMAZING tutorial on ds_maps for saving data, but I can't seem to find a place where he used "ds_map destroy" and that's a little concerning. Do you need to use it at the end of the game, or does it matter? And did he use it at any point or am I blind?

    Here's his project files and the video in question:
    https://www.dropbox.com/s/tslhegjtgr8n7uk/DsMapSavingTutorialAdvanced.gmz?dl=0

     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,028
    13:45 shows ds_map_destroy() being used to wipe away the old map before loading in a new one. The new map will last until the end of the game or the next load, whichever comes first.

    Data structures and other dynamically allocated resources that are intended to last until the end of the game do not need to be explicitly destroyed. As part of ending the game, all runtime resources used by the game would be freed back into the OS anyways.
     
  3. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    552
    Oh, well thanks for that. :D I did not know it didn't need to be manually set like that, nice.

    And I did notice him using it when saving files, just good to know that's the only place I need it. Thanks again. ^_^
     
  4. stainedofmind

    stainedofmind Member

    Joined:
    Jun 20, 2016
    Posts:
    695
    ... However, it's good practice to still implicitly destroy them. If you were to one day decide to rework how your game works and say, implement your own "game_restart" function, for example, its really easy to forget about these things and find yourself with a memory leak that's difficult to identify.
     
    CameronScottCreations likes this.
  5. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    552
    Okay, well if I run into that problem down the line I'll find a way to work it in. Thanks!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice