1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Question - IDE Cleanup event - when this was added?

Discussion in 'GameMaker Studio 2 Community Tech Support' started by gnysek, May 10, 2017.

  1. gnysek

    gnysek Member

    Joined:
    Jun 20, 2016
    Posts:
    1,305
    I've just noticed "Clean up" event in objects, which seems to be very, very useful (it's a better version of "on destroy"). Was this added in 2.0.6, or was before and I was so blind to not notice this for two months?
     
  2. LurchBrick

    LurchBrick Member

    Joined:
    Jun 23, 2016
    Posts:
    4
    Might be time to go to the optomitrist and get your glasses rechecked. :) It was definitely in earlier releases.
     
    gnysek likes this.
  3. T-bond

    T-bond Member

    Joined:
    Jun 22, 2016
    Posts:
    37
    It was there. :D I have already used it in the beta.
     
    kumitassu likes this.
  4. TheMagician

    TheMagician Member

    Joined:
    Jun 20, 2016
    Posts:
    59
    Can someone give me an example of how this event improves on the Destroy Event?
    Even after reading the manual it seems to me like it is triggered in the same instances where the Destroy Event would already be called.
     
  5. gnysek

    gnysek Member

    Joined:
    Jun 20, 2016
    Posts:
    1,305
    On Room End / Game End, instance_destroy() isn't called. Also, clean event would "probably" also work on deactivated instances.
     
    Bentley likes this.
  6. Mike

    Mike nobody important GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    2,393
    Clean is ALWAYS called when the instance is freed - like a C++ destructor.
     
    Badger, Bentley, Hyomoto and 3 others like this.
  7. Kuro

    Kuro Guest

    Gnysek, since it appears that you have the Godlike power to discover brand new features and then bend reality so that they have been there all along... if I send you a short list of features please would you look for them in the current build for me? xD
     
    Mick likes this.
  8. Seabass (The Human)

    Seabass (The Human) Member

    Joined:
    Jun 20, 2016
    Posts:
    357
    The cleanup event triggers at times the destroy event doesn't such as when changing rooms.
     
    Bentley likes this.
  9. TheMagician

    TheMagician Member

    Joined:
    Jun 20, 2016
    Posts:
    59
    I guess I wasn't aware of that. Then I can see the advantage of using it.
     
    Bentley likes this.
  10. Kuro

    Kuro Guest

    So I should switch to using the clean up event instead of Game End for cleaning up my data structures?
     
  11. gnysek

    gnysek Member

    Joined:
    Jun 20, 2016
    Posts:
    1,305
    If your object is not persistent, the yes, as this event won't be called if instance doesn't exists! Btw. if game is closing, then Windows will automatically clean all memory, so you don't need to clean on game end - only in mid-game when something isn't needed anymore.
    But "clean up" is the safest in all cases - you know it always be called on destroy :)
     
    Bentley, Seabass (The Human) and Kuro like this.
  12. Seabass (The Human)

    Seabass (The Human) Member

    Joined:
    Jun 20, 2016
    Posts:
    357
    You don't need to clean up anything on game end. Game Maker does this for you when the application closes. The only stuff you should be doing in game end would be file saving and such.

    *Edit*
    Didn't notice @gnysek had said this already.
     
    Bentley and gnysek like this.
  13. stainedofmind

    stainedofmind Member

    Joined:
    Jun 20, 2016
    Posts:
    701
    While this is true, I would still recommend manually ensuring everything is cleaned up, just in case you change your code logic, or how you restart your game, or anything like that. Being lax about cleaning up after your dynamic resources can lead to nasty memory leaks later down the line, and its really easy to do if you've been just letting the OS clean up after you.
     

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